summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--software/ttx/ttx.asm41
1 files changed, 17 insertions, 24 deletions
diff --git a/software/ttx/ttx.asm b/software/ttx/ttx.asm
index 260b380..077d57b 100644
--- a/software/ttx/ttx.asm
+++ b/software/ttx/ttx.asm
@@ -53,7 +53,8 @@ CWENABLE EQU GP0
CWOUT EQU GP1
SCLK EQU GP2
SDAT EQU GP4
-
+CLK_1HZ EQU GP5
+
;; variables
;; page 0 only
ELEMENT EQU H'0040'
@@ -113,7 +114,7 @@ complete EQU .7
movwf STATUS_TEMP
btfss INTCON,INTF
- goto tmr1_int
+ goto clk_1hz_int
ext_int
bcf INTCON,INTF
btfsc RX_STATE,complete
@@ -155,17 +156,16 @@ ext_int_send_csum
goto interrupt_end
-tmr1_int
+clk_1hz_int
bcf STATUS,RP0
- bcf PIR1,TMR1IF
- bcf T1CON,TMR1ON
- clrf TMR1L
- movlw b'10000000'
- movwf TMR1H
- btfsc NVSTATE,safe ; safe mode -> disable scheduler
+ btfss GPIO,CLK_1HZ
+ goto clk_1hz_int_low
+
+ bcf INTCON,RAIF
goto interrupt_end
- bsf T1CON,TMR1ON
+clk_1hz_int_low
+ bcf INTCON,RAIF
movf SECCNT,f
btfss STATUS,Z
decf SECCNT,f
@@ -362,28 +362,23 @@ init
bsf STATUS,RP0
bcf STATUS,RP1
- movlw b'11000011'
+ movlw b'01000011'
movwf OPTION_REG
movlw b'11111100'
movwf TRISIO
- movlw b'00000001'
- movwf PIE1
movlw OSC_LOW
movwf OSCCON
+ movlw b'00100000'
+ movwf IOCA
bcf STATUS,RP0
;; bank 0
movlw b'00010110'
movwf WDTCON
- clrf TMR1L
- movlw b'10000000'
- movwf TMR1H
- movlw b'00000110'
- movwf T1CON
- movlw b'01010000'
+ movlw b'00011000'
movwf INTCON
-
+
movlw b'00000111'
movwf CMCON0
@@ -411,9 +406,6 @@ init
movf BEACON_INT,w
movwf SECCNT
- btfss NVSTATE,safe ; safe mode -> disable scheduler
- bsf T1CON,TMR1ON
-
bsf INTCON,GIE
goto main
@@ -781,7 +773,7 @@ ack_parity
;; MAINLOOP
main
;; this gets called after reset and whenever a wakeup occured
- ;; (after TMR1 overrun or interrupt on GP2)
+ ;; (after GP5 change or interrupt on GP2)
movf SECCNT,f
btfsc STATUS,Z
goto seccnt_zero
@@ -793,6 +785,7 @@ main
seccnt_zero
movf BEACON_INT,w
movwf SECCNT
+ btfsc NVSTATE,safe
call send_beacon
goto powerdown