whitout ovfl_isr it's works perfectly.[code:1:95fa8882c6]
$regfile = "m16def.dat"
$crystal = 16000000
$hwstack = 32
$swstack = 8
$framesize = 32
$baud = 38400
'Config Portb.4 = Output 'for test
On Int0 Int0_isr
On Int1 Int1_isr
Config Int0 = Rising 'start TIMER1
Config Int1 = Falling 'stop TIMER1
Enable Int0
Enable Int1
Config Timer1 = Timer , Prescale = 1
'On Timer1 Timer1_isr
Enable Timer1
Enable Interrupts
Dim Ovf_1 As Byte
Dim L As Byte
Dim H As Byte
Dim Hl As Word
Dim Hl_old As Word
Do
If Hl <> Hl_old Then
Print Hl
Hl_old = Hl
End If
Loop
End
'------------------
Int0_isr:
Timer1 = 0 'reset timer
Start Timer1
Return
'------------------
Int1_isr:
Stop Timer1
L = Tcnt1l
H = Tcnt1h
Hl = H * 256
Hl = Hl + L
Return
'-------------------[/code:1:95fa8882c6]
The reading is stable for so far my lf generator is stable. Only the last number jumps 1 or 2 digits.
X-tal on 16Mhz, prescale 1: resolution is .0625µS. The maximum reading is: &HFFFF*.0625=4.096mS.(= 122Hz). For f<122Hz then ovfl comes in action. There is the problem. On LSB of TCNT1L + the reading go from 65535 to 65536 unhesitatingly ! At least i'm missing 4 bits. I can prescale on 8 but then i lose resolution. How to do?
↧