View previous topic :: View next topic |
Author |
Message |
eliveltonsantos
Joined: 19 Nov 2012 Posts: 4 Location: São Paulo - Brazil
|
PIC 18F4431 with PLL to 40MHz |
Posted: Mon Nov 19, 2012 1:41 pm |
|
|
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
|
|
Posted: Mon Nov 19, 2012 2:05 pm |
|
|
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
|
|
Posted: Mon Nov 19, 2012 2:12 pm |
|
|
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
|
|
Posted: Mon Nov 19, 2012 3:27 pm |
|
|
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
|
|
Posted: Mon Nov 19, 2012 3:44 pm |
|
|
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
|
|
Posted: Tue Nov 20, 2012 11:11 am |
|
|
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
|
|
Posted: Tue Nov 20, 2012 2:11 pm |
|
|
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
|
|
Posted: Wed Nov 28, 2012 6:10 pm |
|
|
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#. |
|
|
|