Thanks Kurt!
I see a multiplier and a divider, what rate does this timer then count at? 1mS (1KHz)?
Although I think you're providing a "get time" function. That means one has to "poll" to wait for a specific time.
I want to set up a timer to generate an interrupt at a 1Khz rate. Can we write an interrupt handler in Basic Atom? This interrupt handler would then do the following:
Code:
SystemTick2 = SystemTick2 + 1 ; 1mS timer for delays
Tickcount = Tickcount -1
if (Tickcount = 0) then
Tick = TRUE; ; Tick rate 100mS
Tickcount = 100;
endif
I suppose it could all be in assembly, as long as the two variables, Tick and SystemTick2 were accessible from Basic.
in use, I clear SystemTick2, then check periodically for it to reach a prescribed value. Similarly, the Tick flag is checked in a main loop, and if it is set, a subroutine is called, and then the flag is reset. This way, there is no "Blocking" for functions.
Tick allows me to service stuff like sensors at a periodic rate of 10/sec, and SystemTick2 allows me (typically in a state machine) to "check back" and then proceed to the next state when SystemTick2 reaches a preset value. Basically simple "real time" stuff.
thanks,
Alan