Pro28 Timer code + Hardware serial -> Reboot

Hello,

This code from davebr work for ~1ms Timer :

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

Pascal

I solve my problem :

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

--------------------------Sample 2 WORK----------------------

poutvfd con p12
bvfd con i57600

ONINTERRUPT TIMERAINT,IntHandler
TMA = (TMA & 0xF0) | 0x4 ;Sets TimerA to increment once
;every 256 clock cycles.
timer var long
ENABLE TIMERAINT

sound P9, [100\1000]
main
serout poutvfd, bvfd, [dec timer, " "]
pause 10
GoTo main

IntHandler
timer = timer + 1
resume

But I must disable timer interrupt before use serin / serout :frowning:

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…

Kurt

Hi,

I use 8.0.1.3, this version appear more reliable for soft serial I/O.

I have somes minor problems :

  1. “pause 1” or “pause 5” when I use soft Serout after Hserial in certain cases (only two cases).

(My robot have primary command data (wireless tcp-ip server) on hardware serial of atompro28, and all slaves devices / peripherals on soft serial I/O)

  1. Very Rarely : I lost one or two byte on soft serial…

How you compile with non standard UART speed ?
[edit]What is the last beta version and where is changelog if exist?

Thanks for your very interesting informations.
Pascal