Hi,
Something must be wrong with your setup. I tried the same ISR as your one, with InterruptFrequency = 10800:And I get ~10500Hz even when running at 20Mhz. Here you can see that I, instead of using TOGGLE set the output high at the entry point and low at the exit which allows me to measure the execution time of the code in between. This exact code executes in ~3us on this 18F4520 running at 20MHz, if you try the same on yours it should be 1.5us - if it's not then you're not running at 40MHz.Code:' ---------- Interrupt handler ------------ TimezUp: PortB.3 = 1 T1CON.0 = 0 ' Stop TMR1 TMRCopy.HighByte = TMR1H ' Copy value of TMR1 registers TMRCopy.LowByte = TMR1L TMRCopy = TMRCopy + TimerReloadValue ' Add reload value (compensates for overhead) TMR1H = TMRCOPY.HighByte ' And back to TMR1 TMR1L = TMRCopy.LowByte T1CON.0 = 1 ' Restart Timer PortB.3 = 0 @ INT_RETURN
You say you have a 40MHz x-tal, is that really correct? To run at 40MHz with the PLL you should use a 10MHz x-tal.
Try the above, what's the pulsewidth on the output? If it's not 1.5us you're not running at 40MHz.
/Henrik.




Bookmarks