Yes of course it does. I thought we came to the conclusion that you couldn't use Darrels timer template because it calculated the reload value at
build time and you wanted to calculate it at
runtime. Now you're trying to use it anyway....I don't get it.
Code:
INCLUDE "DT_INTS-18.bas"
INCLUDE "ReEnterPBP-18.bas"
InterruptFrequency VAR WORD
Dummy VAR WORD
Dummy2 VAR WORD
Dummy3 VAR WORD
TMRCopy VAR WORD
TimerReloadValue VAR WORD
Dummy2 = 10000
Dummy3 = 10000
InterruptFrequency = 5000
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR1_INT, _TimezUp, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
@ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts
TRISB.3 = 0 ' Output to measure interrupt frequency
CMCON = 7
ADCON1 = %00001111 ' No analog inputs.
T1CON.0 = 1 ' Start TMR1
Dummy = Dummy2 * Dummy3
TimerReloadValue = Div32 InterruptFrequency
TimerReloadValue = 65535 - TimerReloadValue + 1
LCDOUT $FE,1,"F: ", #InterruptFrequency, " Reload: ", #TimerReloadValue
Main:
Pause 20
Goto Main
' ---------- Interrupt handler ------------
TimezUp:
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
Toggle PortB.3
@ INT_RETURN
Bookmarks