This is the initialization code.
let tmrw=%10001000 ;set Timer Mode Register to enable count
let tcrw=%10110000 ;set Timer Control Register clear on compare match A
let gra=2000 ; 16 MHz clock /8 prescalar S = 2 MHz timer clock / 2000 = 1 mS
let time_count=0 ;reset real time count
oninterrupt timerwint_imiea, tm_isr ;setup interrupt routine
enable timerwint_imiea ;enable timer interrupt
This is the interrrupt code.
tm_isr:
let time_count=time_count+1 ;increment real time count
resume
But reboot If I use enablehserial (before or after this code)
The manual 8.0.0.0 sample timer work but same problem if I use hserial.
Do you have solution for simple timer + hserial ?
I need very basic Timer, 10ms increments on var Word is good for me
The interrupt handler code must placed at END of program !!!
(Samples use a serial VFD to display timer. make some errors byte @56K)
--------------------------Sample 1 WORK----------------------
poutvfd con p12
bvfd con i57600
time_count var long
Let tmrw=%10001000 ;set Timer Mode Register to enable count
let tcrw=%10110000 ;set Timer Control Register clear on compare match A
let gra=2000 ; 16 MHz clock /8 prescalar S = 2 MHz timer clock / 2000 = 1 mS
let time_count=0 ;reset real time count
oninterrupt timerwint_imiea, tm_isr ;setup interrupt routine
enable timerwint_imiea ;enable timer interrupt
sound P9, [100\1000]
main
serout poutvfd, bvfd, [dec time_count, " "]
pause 10
GoTo main
tm_isr:
let time_count=time_count+1 ;increment real time count
resume
Yes I also do disable my timer interrupt when I am doing serin/serout. I found that at 2400 baud I could probably keep the interrupt running, but above that I could not.
One experiment I tried with a little success is to try to cheat on the baud rate. For example i9600 is a numeric value. The formula for this is in a couple of different threads. I then tried cheating by decrementing the value to say that I am trying to output at something like i9625, knowing the overhead of the timer was slowing the processor down.
Also AcidTech mentioned that he was adding support for asembler level interrupt handlers. If that is in the current beta you might try that and see if you can reduce the overhead enough…