;
; Master Slave
; Timer 0 nmra Disabled
-; Timer 2 (10ms tick, int. low) -
+; Timer 2 tick: 10ms, int. low -
; Timer 1 - -
; CCP1 - -
; Timer 3 point fire timer point fire timer
; after ticker_init, and after interrupts enabled,
; we call <foo>_tick every 10ms.
+ include common.inc
+ code
+
;----------------------------------------
ticker_init
-; Timer 2 not used used for ticker
+; Timer 2 any used for ticker
+ mov_lw tick_timer2scale ; disable (in case already running)
+ mov_wf T2CON
mov_lw tick_timer2period
mov_wf PR2
- mov_lw tick_timer2scale | (1<<TMR2ON)
-
+ bc_f PIR1, TMR2IF ; clear any previous interrupt
+ bc_f IPR1, TMR2IP ; low priority
+ bs_f IPR1, TMR2IE ; enable interrupts
+ bs_f T2CON, TMR2ON ; enable timer
+ return
- mov_lw b'1011' ; Compare mode, Special event
- mov_wf CCP1CON
+;----------------------------------------
+ticker_intrl
+ bt_f_if0 PIR1, TMR2IF
+ return
+ ; we have an interrupt
- t3con
- t1con
+ bc_f PIR1, TMR2IF
- clr_f TMR1L
- clr_f TMR1H
+ ; add calls to <foo>_tick here:
+ call cdu_tick
+ ; end of list of calls to <foo>_tick
- bc_f IPR1, TMR1IP
- bc_f IPR1, CCP1IP
- bc_f PIR1, TMR1IF
- bc_f PIR1, CCP1IF
- bs_f PIE1, TMR1IE
- bs_f PIE1, CCP1IE
+ intrl_handled_nostack
-T3CCP2
+;----------------------------------------------------------------------
+ include final.inc