I'm revisiting my old project for a bigger job now. I'm configuring the timing for my PIC18F4455 with a 1000-ms delay for a blinking LED using MikroC. I'm using a 20-MHz crystal oscillator.
Now, I understand that you have to set the speed from the configuration settings. Here's mine:
However, the blinking period doesn't match the computer clock (I watch the sync between the clock ticking and the LED blink) which I'm using as a reference. It seems the PIC is going a tad bit faster but definitely noticeable. This has made my subsequent programming (which involves UART and other comm protocols) a problem.
I've tried some combinations like changing the Prescaler, CPU postscaler, and whatnot but this hasn't helped. I've definitely understood this whole clocking part poorly.
Anybody can point me in the right direction?
Thanks.
Vizier87
EDIT: I've set the oscillator as 19 MHz as part of my attempts to see if this makes it more accurate. It seems to have changed but still a very messy thing to do. Hasn't worked also though.
Any thoughts on how I should approach it? I've been changing the values between 20-25 MHz. The closest accuracy I could achieve is 23. But still not good enough.
I don't use MikroC for 8 bit only 32bit! But when I use an 8Mhz crystal and PLL to 80Mhz, the setting is for the latter.
I wouldn't think you would see much difference 20 ~ 25Mhz on an led A 1 second pulse at 20Mhz will be .8mS at 25Mhz , agreed! With USART there will be a great difference..
Looking at the CPU clock... (osc1 / osc2 ) / 3 = 6.66Mhz ??? Is there another option here?
I don't use MikroC for 8 bit only 32bit! But when I use an 8Mhz crystal and PLL to 80Mhz, the setting is for the latter.
I wouldn't think you would see much difference 20 ~ 25Mhz on an led A 1 second pulse at 20Mhz will be .8mS at 25Mhz , agreed! With USART there will be a great difference..
Looking at the CPU clock... (osc1 / osc2 ) / 3 = 6.66Mhz ??? Is there another option here?
The whole thing is a poor man's work. Just trying to earn something from here if what follows would work. No wonder my previous transmission with an Xbee was totally in disarray!
Thanks a million, Ian. I'm gonna put your name in my code.