I have been playing with the code shown below on a 16f737 as I was trying to get different prescaler values into the int routinues. As part of the testing I stripped the code right back to just be a simple interrupt with a value loaded into the pre-load registrer, but I seem to end up with an interrupt time of 204uS. According to the Timer Calc in Mister E's PicMulti Calc I should get an interrupt every 5.019mS. (see attached image for capture of the output waveform - I love my PICkit 2!)
This code is lifted straight from Darells example with the blinky led (1-2-3 version), and all I have done is add the pre-load. I have also removed the pre-load and still get the same time for the interrupt.
Code:
DEFINE OSC 20
rs_led var portb.7 ' rs232 led
led var portc.4 ' was Data_Out line
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
INCLUDE "DT_INTS-14.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR0_INT, _doBAM, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
OPTION_REG = OPTION_REG & $80 | 1 'Set TMR0 Prescaler to 256, leave RBPU alone
TMR0 = 158 ' preload with 158 to give 21uS interrupts (at 1:1)
' this should then give Interrupt every 5.019mS at 1:256
@ INT_ENABLE TMR0_INT ; enable Timer 1 interrupts
'~~~~~~~~~~~~~~~~~~
goto main ' jump over ISR
'---[TMR0 - interrupt handler]--------------------------------------------------
doBAM:
toggle rs_led
@ INT_RETURN
'~~~~~~~~~~~~~~~~~~~~~~~~~~~
high rs_led
main:
'''''''''''''''''''''''
' do some flashing led stuff
'''''''''''''''''''''''
high led
pause 500
low led
pause 500
goto main
There has got to be something really simple I am missing...
bill.
Bookmarks