; *************************************************************************** ; defs .equ TIMER_FLAGS_100MS = 1 .equ TIMER_FLAGS_1S = 2 .equ TIMER_CALLBACK_10S = 0x01 .equ TIMER_CALLBACK_30S = 0x02 .equ TIMER_CALLBACK_1M = 0x04 .equ TIMER_CALLBACK_15M = 0x08 .equ TIMER_CALLBACK_30M = 0x10 .equ TIMER_CALLBACK_1H = 0x20 .equ TIMER_CALLBACK_12H = 0x40 .equ TIMER_CALLBACK_1D = 0x80 ; *************************************************************************** ; data .dseg timerModuleData: timerModuleTickCounter: .byte 1 ; only low byte used timerModuleFlags: .byte 1 timerModuleCounterSecs: .byte 4 timerModuleDerivedCounters: ; order of the following vars matters!! timerModuleCounterFor10s: .byte 1 ; change Timer_IncrementCounters when changing the timerModuleCounterFor1m: .byte 1 ; order here! timerModuleCounterFor15m: .byte 1 timerModuleCounterFor30m: .byte 1 timerModuleCounterFor1h: .byte 1 timerModuleCounterFor12h: .byte 1 timerModuleCounterFor1d: .byte 1 timerModuleData_end: ; *************************************************************************** ; code .cseg ; *************************************************************************** ; Timer_Init ; ; IN: ; - nothing ; OUT: ; - nothing ; USED: r16, r17, x Timer_Init: ; setup timer for 15.2588 interrupts per second (e.g. every 65.5 ms) ; reset data in SDRAM ldi xh, HIGH(timerModuleData) ldi xl, LOW(timerModuleData) ldi r16, 0 ldi r17, (timerModuleData_end-timerModuleData) rcall Utils_FillSram ; CTC mode (WGM2:0=2, OCR0A=value, OCF0A Flag =1, -> IRQ_OC0A ; CMP-A interrupt about every 100ms ldi r16, (1<