I've migrated code running on a PIC16C54 to a PIC18F1320. Both use an external RC network. On the OSC2 pin both processors show a nice clock at 25 KHz (which is correct). However, the 18F1320 seems to be executing code at twice the speed! Have I overlooked something?
It's not executing the code twice speed, same C routine may generate fewer instructions on 18Fxxx than 16Cxx and fewer instructions execute faster. Depends on your usage of arrays and pointers but twice the speed sounds just right.
I seem to recall that some of the higher-end PICs execute an instruction in 2 OSC clock cycles rather than the usual 4 clock cycles. Check the data sheet for that.
How about your layout and bypassing? You're not using a solderless breadboard are you? The RC capacitor lead ('Cext' in Microchip-hua) should go directly back to a Vss pin on the micro and *nowhere else*. At least 0.1uF ceramic in parallel with something like 10uF-100uF electrolytic, with the ceramic especially directly across Vdd-Vss very near the chip.
With such a slow clock speed, and some kind of layout or bypassing issue, it's entirely possible you're getting a hiccup of a few hundred ns on one of the clock edges, which is double-clocking the core. The PIC18F series is faster than the older 16C series and will likely be less tolerant of such things.
Best regards, Spehro Pefhany
--
"it's the network..." "The Journey is the reward"
speff@interlog.com Info for manufacturers: http://www.trexon.com
The micro is on a SMD populated 4-layer PCB and Cext is connected directly to VSS. In addition, there is a 100nF cap close to the micro supply pins. I'm still investigating...
Okay, we can certainly rule that out. If you're not making a mistake in your evaluation of the execution speed, it's almost looking like a silicon problem. I doubt ext. RC clock is very often used with the 18F series.
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth..
Best regards, Spehro Pefhany
--
"it's the network..." "The Journey is the reward"
speff@interlog.com Info for manufacturers: http://www.trexon.com
Roman, thanks for the reply. I double checked with a small delay routine on the 16c54 and 18f1320 and it is exactly 2x speed. Thanks for the errata link, I'll investigate further.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.