summaryrefslogtreecommitdiff
path: root/software/ttx/ttx.asm
diff options
context:
space:
mode:
Diffstat (limited to 'software/ttx/ttx.asm')
-rw-r--r--software/ttx/ttx.asm36
1 files changed, 23 insertions, 13 deletions
diff --git a/software/ttx/ttx.asm b/software/ttx/ttx.asm
index 38b9254..b6b7bbb 100644
--- a/software/ttx/ttx.asm
+++ b/software/ttx/ttx.asm
@@ -32,11 +32,11 @@
LIST p=12F635
include "p12f635.inc"
- __config _WUREN_ON & _FCMEN_OFF & _IESO_OFF & _BOD_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT
+ __config _WUREN_OFF & _FCMEN_OFF & _IESO_OFF & _BOD_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT
;; -------------------------------------
;; DEFINES
-BEACON_INT EQU .3 ; *2 = Beacon Interval in seconds
+BEACON_INT EQU .21 ; *2 = Beacon Interval in seconds
SECCNT EQU H'007D'
CHAR EQU H'0041'
@@ -60,25 +60,31 @@ STATUS_TEMP EQU H'007F'
;; -------------------------------------
;; Reset Vector
- org 0
+ org .0
goto init
;; -------------------------------------
;; Interrupt Vector
- org 4
+ org .4
;; save context
movwf W_TEMP
swapf STATUS,W
movwf STATUS_TEMP
- btfss INTCON,INTF
+ bcf STATUS,RP0
+ bcf STATUS,RP1
+
+ btfsc PIR1,TMR1IF
goto tmr1_int
ext_int
;; TODO: read bit from GPIO,SDAT and add to received string
goto interrupt_end
tmr1_int
- decf SECCNT,f
+ bcf PIR1,TMR1IF
+ movf SECCNT,w
+ btfss STATUS,Z
+ decf SECCNT,f
interrupt_end
;; restore context
@@ -99,7 +105,7 @@ init
movwf OPTION_REG
movlw b'11111100'
movwf TRISIO
- movlw b'10000001'
+ movlw b'00000001'
movwf PIE1
movlw b'00000000'
movwf OSCCON
@@ -107,13 +113,16 @@ init
bcf STATUS,RP0
;; bank 0
- movlw b'01010000'
- movwf INTCON
+ clrf TMR1L
+ clrf TMR1H
movlw b'00000111'
movwf T1CON
+ movlw b'01000000' ; enable external interrupt bit4
+ movwf INTCON
+
movlw b'00000111'
movwf CMCON0
-
+
bcf GPIO,CWOUT
bcf GPIO,CWENABLE
@@ -329,13 +338,14 @@ main
btfss STATUS,Z
goto powerdown
- ;; this gets called every BEACON_INT*2 seconds
+ ;; this gets called every 2*BEACON_INT seconds
movlw BEACON_INT
- movwf SECCNT
+ movwf SECCNT
call send_beacon
-
+
powerdown
sleep
+ nop
goto main
;; -------------------------------------