OS_Hardware%=&7A
HAL_Timers%=12
HAL_TimerDevice%=13
HAL_TimerGranularity%=14
HAL_TimerMaxPeriod%=15
HAL_TimerSetPeriod%=16
HAL_TimerPeriod%=17
HAL_TimerReadCountdown%=18
HAL_CounterDelay%=22
SYS OS_Hardware%,,,,,,,,,0,HAL_Timers% TO timers%
PRINT timers%;" timers found"
FOR timer%=0 TO timers%-1
SYS OS_Hardware%,timer%,,,,,,,,0,HAL_TimerDevice% TO device%
SYS OS_Hardware%,timer%,,,,,,,,0,HAL_TimerGranularity% TO gran%
SYS OS_Hardware%,timer%,,,,,,,,0,HAL_TimerMaxPeriod% TO maxperiod%

PRINT "Timer ";timer%;" is device ";device%;" at ";gran%;" ticks/second, maximum period ";maxperiod%
SYS OS_Hardware%,timer%,,,,,,,,0,HAL_TimerPeriod% TO period%
PRINT "Current period is ";period%;" ticks or ";(period%/gran%)*1E6;" microseconds."
PRINT "Time now is:"
PRINT "Timer","TIME/cs"
FOR i%=0 TO 10
SYS OS_Hardware%,timer%,,,,,,,,0,HAL_TimerReadCountdown% TO time%
FOR j%=0 TO 10000:NEXT j%
PRINT time%,TIME
NEXT i%
NEXT timer%
PRINT "Delaying 10s"
t%=TIME
SYS OS_Hardware%,10E6,,,,,,,,0,HAL_CounterDelay%
t2%=TIME
PRINT "Done, took ";(t2%-t%)/100;"s (according to the OS using the same timer!)"'
END


