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?
Thanks in advance for any help?
Simon
Didn't find your answer? Ask the community — no account required.
R
Roman Ziak
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.
Roman
P
PigPOg
The code is written in assembly language. I can't see that this would make a difference.
Thanks for the reply. Simon
R
Robert Scott
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.
Robert Scott Real-Time Specialties
Robert Scott Ypsilanti, Michigan
P
PigPOg
Thanks Robert, I'll check that out.
Simon
S
Spehro Pefhany
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
Embedded software/hardware/analog Info for designers: http://www.speff.com
P
PigPOg
Spehro
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...
Regards, Simon
S
Spehro Pefhany
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
Embedded software/hardware/analog Info for designers: http://www.speff.com
R
Robert Scott
for
I take it back. The PIC24H series is the one with the 2x clock. I think all PIC18s have a 4x clock.
Robert Scott Ypsilanti, Michigan
R
Roman Ziak
Just curious, hos did you determine it was 2x speed ? It is exactly twice or approximate ?
Btw. check errata for this chip, it seems it has several problems with internal RC oscillator.
formatting link
Roman
P
PigPOg
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.
Regards, Simon
P
PigPOg
Gulp! How embarrassing. There's an error in code migration. Fixed now, sorry to bother everyone - must re-check thoroughly next time before posting.
Thanks all, Simon
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required
Report Content
You are reporting this content to the moderators. They will look at it
ASAP.