CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC 18F4431 with PLL to 40MHz

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
eliveltonsantos



Joined: 19 Nov 2012
Posts: 4
Location: São Paulo - Brazil

View user's profile Send private message MSN Messenger

PIC 18F4431 with PLL to 40MHz
PostPosted: Mon Nov 19, 2012 1:41 pm     Reply with quote

Hi,

I'm using PCWHD Compiler version 4.068 and the PIC 18F4431.
I'm trying to use the Phase Locked Loop (PLL), but isn't work. I put a crystal 10MHz (from pin 13 to 14) with 2 capacitors 22pF (to Vss) and a yellow LED with your resistor on pin 20.
Follow down the source code:

Code:

#INCLUDE <18F4431.h>
#USE  DELAY (CLOCK = 40M)

#FUSES   H4          // High speed osc with HW enabled 4X PLL
#FUSES   PUT         // Power Up Timer
#FUSES   NOBROWNOUT  // No brownout reset
#FUSES   NOWDT       // No Watch Dog Timer
#FUSES   NOMCLR      // Master Clear pin used for I/O
#FUSES   NOLVP       // No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES   NOPROTECT   // Code not protected from reading
#FUSES   NOCPD       // No EE protection

void main (void)
{
   output_low (pin_d1);
   
   while (true)
   {   
      output_toggle (pin_d1);
      delay_ms (2000);
   }
}


I don't get that the LED toggle on right time. It never toggle before 2 seconds: the toggle time is desynchronized.

If someone have an idea about the problem, tell me please.
_________________
Santa Bárbara d'Oeste - São Paulo - Brasil
Experiência em CCS e C#.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 19, 2012 2:05 pm     Reply with quote

I installed vs. 4.068 and tested your program in hardware with an 18F4431
and it works perfectly. I timed the LED blinking with a stopwatch and it's
4.0 seconds for a complete On-Off cycle (2 seconds On and 2 seconds off).

I'm using a PicDem2-Plus board with a 10 MHz crystal, and the board
runs at +5v.
eliveltonsantos



Joined: 19 Nov 2012
Posts: 4
Location: São Paulo - Brazil

View user's profile Send private message MSN Messenger

PostPosted: Mon Nov 19, 2012 2:12 pm     Reply with quote

I'm doing this on the protoboard and it doesn't work!
It's so crazy.
_________________
Santa Bárbara d'Oeste - São Paulo - Brasil
Experiência em CCS e C#.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 19, 2012 3:27 pm     Reply with quote

Try it with the internal oscillator (INTRC_IO fuse) instead of the H4 fuse.
Change the #use delay to 4 MHz.
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Mon Nov 19, 2012 3:44 pm     Reply with quote

What speed does it toggle?.
Obvious 'most likely thing' is that there is a problem with the crystal/loading capacitors, the oscillator is not running, and the chip defaults to dropping back to the internal oscillator.
So measure the actual toggle speed, and then work out what oscillator it is actually using....

Best Wishes
eliveltonsantos



Joined: 19 Nov 2012
Posts: 4
Location: São Paulo - Brazil

View user's profile Send private message MSN Messenger

PostPosted: Tue Nov 20, 2012 11:11 am     Reply with quote

I replaced all my circuit but the error is the same. Watch the video.

INTRC and INTRC_IO fuses don't work. I had to manually program using #BYTE OSCCON = 0xFD3 and OSCCON = 0b01111000; but it isn't work up to 8MHz.
Today, I work on 20MHz but I need work on 40MHz.

If I use a 4MHz crystal and program to #USE DELAY (CLOCK = 16000000) and #FUSES H4 the PIC works so good.
_________________
Santa Bárbara d'Oeste - São Paulo - Brasil
Experiência em CCS e C#.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Nov 20, 2012 2:11 pm     Reply with quote

I think your problems are mostly caused by the breadboard circuit.

1. Your power and ground connections appear to consist of wires wrapped
around banana plugs 2 or 3 times. That's a very poor connection. It
can easily be intermittent. You need to change it to use alligator clips.

2. You don't have any 0.1 uF ceramic capacitors between the Vcc pins
and ground, on the PIC. This can cause erratic operation of the PIC.
The capacitors need to be placed very close to the Vcc and ground pins
of the PIC.

3. You don't appear to have any power and ground connections to the
AVdd and AVss pins on the PIC. This will result in erratic operation.
You also need a 0.1 uF ceramic capacitor connected between these two pins.

4. Your breadboard is not the best type. Your breadboard does not
have power and ground bus strips along the sides of the boards. These
are usually marked with red and blue stripes.
This photo shows an Atmel chip, so it's not exactly the same as a PIC,
but it's similar. Notice the 3 small yellow capacitors. These are all 0.1 uF
capacitors. The Atmel chip requires 3 caps. The 18F4431 only needs 2
caps (on the power and ground pins).
http://4.bp.blogspot.com/-_RhMtgM80QM/UHBDTNo1uCI/AAAAAAAAA5o/352kpdjqP98/s1600/mega1284_breadboard.jpg

Here's an example of a breadboard with the power and ground busses
that run the length of the board. These busses are marked with red for
power and blue for ground. The black wires are for ground. Notice how
easily you can connect the microcontroller pins to power and ground.
http://farm4.static.flickr.com/3467/3825462748_c43f938231.jpg
He has a mistake. He left off the 0.1 uF bypass capacitors, but at least
this photo gives you an example.
eliveltonsantos



Joined: 19 Nov 2012
Posts: 4
Location: São Paulo - Brazil

View user's profile Send private message MSN Messenger

PostPosted: Wed Nov 28, 2012 6:10 pm     Reply with quote

I put two 100nF capacitors next to Vdd/Vss. The problem was noises in power.
I did some changes to my application on axes control with the newer clock and it was perfect works.

Thanks guys.
_________________
Santa Bárbara d'Oeste - São Paulo - Brasil
Experiência em CCS e C#.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group