I'm using FF v3.8 on a PIC18F46K22 using a 12.288MHz crystal and x4 PLL, so the clock is 49.152MHz.
I know from previous PIC projects using this clock I can produce a 1mS interrupt using TMR2 with a prescale of 4, postscale of 16 and a timer comparison value for PR2 of 191.
So I noticed that FF v3.8 did not produce an accurate 1mS interrupt. It gives 1.0052mS. (PR2 is set to 192)
Found the bug in p18f-main.cfg. The formula for setting up TMR2 is incorrect.
I'm using FF v3.8 on a PIC18F46K22 using a 12.288MHz crystal and x4 PLL, so the clock is 49.152MHz.
I know from previous PIC projects using this clock I can produce a 1mS interrupt using TMR2 with a prescale of 4, postscale of 16 and a timer comparison value for PR2 of 191.
So I noticed that FF v3.8 did not produce an accurate 1mS interrupt. It gives 1.0052mS. (PR2 is set to 192)
Found the bug in p18f-main.cfg. The formula for setting up TMR2 is incorrect.
constant tmr2prescaler = d'4'
constant tmr2postscaler = d'16'
constant tmr2ms_val=(clock/d'4000'/tmr2prescaler/tmr2postscaler)
Should be
constant tmr2prescaler = d'4'
constant tmr2postscaler = d'16'
constant tmr2ms_val=(clock/d'4000'/tmr2prescaler/tmr2postscaler)-1
Regards Steve.
Last edit: Steve Jones 2013-05-11
Thanks Steve,
I'll fix it.
Best regards
Mike