PDA

View Full Version : 18F2510 help



peterdeco1
- 30th December 2006, 11:55
Hello Everyone. I recently added code to a program compiled for a 16F76 and it wouldn't fit in the PIC. So I compiled it for a 18F2510 and the timing seems to be off. Certain sections of the code seem to run slower while other sections run a little too fast. Does anyone have any suggestions? I changed adcon1 = 7 to adcon1 = 15 for the 18F PIC. I also had to remove my @device line to compile without errors. I then set the config bits within MPLAB before programming. Thank you.

mister_e
- 30th December 2006, 13:20
Just make sure that all register match from one to another. Sometimes, some specific bits on a device are not located at the same place on another one.

If you don't mind, post your code here.

peterdeco1
- 30th December 2006, 13:41
Thanks Steve. One interesting thing is the beginning of the program runs slow - delays that are supposed to last only 1/2 second take 2 seconds to complete. I was able to eliminate this by changing the Watchdog Postscaler from it's default of 1:128 to 1:8. However, later in the program there are delays that are supposed to last up to 6 seconds but finish in about 4-1/2 seconds. Any ideas?? - Thank you.

mister_e
- 30th December 2006, 13:47
I didn't check the datasheet but, are you using the internal OSC (if there's) ?

try the eternal Led Blink first and post your observations here.

peterdeco1
- 30th December 2006, 13:51
Hi Steve. The circuit uses a 4MHZ ceramic resonator. Again, the 16F76 worked perfectly until I compiled it for 18F2510. I must be missing something???

Ron Marcus
- 30th December 2006, 14:09
Hi Steve. The circuit uses a 4MHZ ceramic resonator. Again, the 16F76 worked perfectly until I compiled it for 18F2510. I must be missing something???


How are you implementing the delays?

mister_e
- 30th December 2006, 14:15
Weird,
your ADCON setting is good, the comparator are off at POR... so...

Any way to post your config fuses setting here?

peterdeco1
- 30th December 2006, 16:04
What is so weird is that both delays are implemented the same way using the pause command. Changing the Watchdog Postscaler from 1:128 to 1:8 speeds-up one but not the other. The timers are basically like this:
timer:
pause 60
let x = x + 1
if x >= 100 then blahblah
goto timer

This 6 second routine is exactly 6 seconds with the 16F76 but is about 4-1/2 with the 18F2510. Changing the Watchdog Postscaler has no effect on this one. Now this 500 MS routine takes 2 seconds and speeds-up to 500 MS with the Postscaler set to 1:8:

if porta.5 = 0 then pause 500 : goto start

I was hoping I was missing something (never used an 18F before). But it looks like it's time to order some new PIC's (I only have 1) I was driven crazy 2 times before by what turned out to be a bad PIC. It's that time of year here when everytime you touch a doorknob you get a shock. Maybe I toasted it. Thanks for the help everybody.