PDA

View Full Version : Timing problem PIC18F2550



ecasto17
- 2nd March 2011, 03:13
Hello,

I recently bought microcode studio and the PBP compiler. I am using the U2 programmer to perform ICSP on my 18F2550 PIC. I can program the chip no problem however the timing is no where near correct. For example I programed an LED to blink every seven seconds and it was blinking around every 5-6 secs. I think that i have the options wrong in the melabs programmer configuration window. As far as ocsillators go i am using a 20MHz crystal oscillator. I know the hardware setup is correct because i used the same hardware a couple of years ago when i was using this stuff in highschool (forgot most of it by now).

I was hoping someone could suggest the options i should use. I want to use the external 20MHz oscillator.

Thanks,

Eric

Charles Linquis
- 2nd March 2011, 03:28
I think you should read the datasheet. The chips with USB have a wide variety oscillator PLL and divider configuations. Your chip is obviously not runnng at 20Mhz - internally, even though the oscillator itself is running 20.

ecasto17
- 3rd March 2011, 23:32
Doesn't the meprogrammer have all the settings built into their little drop down menu? Therefore it should just be a matter of selecting the correct settings correct?

mackrackit
- 4th March 2011, 01:12
Many come here thinking they can use the drop down and many end up learning how to set the configs the "right" way.

This should help you get started on that path.
http://www.picbasic.co.uk/forum/showthread.php?t=543

cncmachineguy
- 4th March 2011, 01:25
I must admit, programming for many years in ASM, I always set my configs through the MPLAB menu. Always worked great, and ALWAYS messed me up when I had to program more chips for the same job. Take the time to learn to set them in your program. You will hate it at first, but later you will be so happy when you don't have to remember how you set them for each application.

sean-h
- 6th March 2011, 11:00
Place
DEFINE OSC 48 at the beginning of your code and you should be sorted.

Cheers

Sean.