evsource
Joined: 21 Nov 2006 Posts: 129
|
H4 Fuse with External Oscillator on 18f14k22 way off! |
Posted: Wed Jul 14, 2010 2:20 pm |
|
|
I'm using PCH version 4.092 with a 18F14K22. I've got a 10.000mHz crystal with 18pF capacitors.
The following, as verified on a scope, gives about the right timing (seems to be about 12us instead of the expected 10, but in the ballpark at least):
Code: | #include <18f14k22.h>
#fuses HS,WDT256,NOMCLR,NOWDT,NOBROWNOUT,BORV22,NOLVP
#fuses NOPROTECT,NOCPD,NOCPB,NOWRT,NOWRTD,NOWRTB,NOWRTC,NOEBTR,NOEBTRB
#use delay(clock=10000000)
void main() {
while(1) {
output_low(PIN_C1);
delay_us(10);
output_high(PIN_C1);
delay_us(10);
}
} |
But when I try to get 40mHz out of it with the following code, the pulse takes 400us! Exactly 40 times what it should.
Code: | #include <18f14k22.h>
#fuses H4,WDT256,NOMCLR,NOWDT,NOBROWNOUT,BORV22,NOLVP
#fuses NOPROTECT,NOCPD,NOCPB,NOWRT,NOWRTD,NOWRTB,NOWRTC,NOEBTR,NOEBTRB
#use delay(clock=40000000)
void main() {
while(1) {
output_low(PIN_C1);
delay_us(10);
output_high(PIN_C1);
delay_us(10);
}
} |
Is this a compiler bug? Could someone compile this code with a newer version and PM the hex file to me so I can try it? |
|