chiark / gitweb /
timer2 ticker wip
authorian <ian>
Tue, 20 Dec 2005 18:08:50 +0000 (18:08 +0000)
committerian <ian>
Tue, 20 Dec 2005 18:08:50 +0000 (18:08 +0000)
detpic/common.inc
detpic/master.asm
detpic/tick.asm

index f798a75f2be38af059855a875224b540b227ab54..d8429605287514c1d2c1aad7cc40e4bafdae1921 100644 (file)
@@ -74,7 +74,7 @@ clock equ -1
 ;
 ;                      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
index 87711aaf651b1bafae3ca2f391016f8cb96f6e59..6d5525a54fe4e54f0a8515369648e99b99495b14 100644 (file)
@@ -37,6 +37,7 @@ master
 ;----------
 master_interrupt_low
        enter_interrupt_low
+       call    ticker_intrl
        call    nmra_serialrx_intrl
        ;call   serialtx_intrl
        call    points_local_intrl
index 70a90950a2e1a069da29101581feee77158acd88..1424ae3d4f8e1dd8b017c15d966182bef20d1491 100644 (file)
@@ -4,28 +4,35 @@
 ; 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