summaryrefslogtreecommitdiff
path: root/software
diff options
context:
space:
mode:
authorChristian Pointner <equinox@mur.at>2011-07-24 19:42:40 +0000
committerChristian Pointner <equinox@mur.at>2011-07-24 19:42:40 +0000
commitc347624b6bd7ba35ca4aa2a4df1060d8e86d16d5 (patch)
tree7acf721b649785e177ebbd80c86da127297751e0 /software
parentihu and ttx reset works now (diff)
uart recv works
git-svn-id: https://svn.spreadspace.org/mur.sat@51 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software')
-rw-r--r--software/ihu/ihu.asm84
1 files changed, 73 insertions, 11 deletions
diff --git a/software/ihu/ihu.asm b/software/ihu/ihu.asm
index 3f49483..9c762f6 100644
--- a/software/ihu/ihu.asm
+++ b/software/ihu/ihu.asm
@@ -40,12 +40,18 @@
;; constants
;; I/O Pins
+DTMF_D0 EQU 0
+DTMF_D1 EQU 1
+DTMF_D2 EQU 2
+DTMF_D3 EQU 3
+DTMF_PWRDWN EQU 4
TTX_RESET EQU 5
-
+TTX_SCL EQU 6
+TTX_SDA EQU 7
+
;; variables
;; page 0 only
-CNT0 EQU H'0020'
-CNT1 EQU H'0021'
+TMP EQU H'0020'
;; all pages
W_TEMP EQU H'007E'
@@ -69,7 +75,21 @@ STATUS_TEMP EQU H'007F'
bcf STATUS,RP0
bcf STATUS,RP1
- ;; TODO: implement interrupt service routines
+ btfsc PIR1,RCIF
+ goto int_uart_rx
+ goto interrupt_end
+
+int_uart_rx
+ call uart_rx_byte
+ btfsc PIR1,RCIF
+ call uart_rx_byte
+ btfss RCSTA,OERR
+ goto int_uart_rx_oe
+ goto interrupt_end
+
+int_uart_rx_oe
+ bcf RCSTA,CREN
+ bsf RCSTA,CREN
interrupt_end
;; restore context
@@ -82,26 +102,48 @@ interrupt_end
;; -------------------------------------
;; INIT
init
- ;; bank 1
+ ;; bank 3
bsf STATUS,RP0
- bcf STATUS,RP1
+ bsf STATUS,RP1
+ movlw b'00000000'
+ movwf BAUDCTL
+ ;; bank 1
+ bsf STATUS,RP0
+ bcf STATUS,RP1
movlw b'11000111'
movwf OPTION_REG
clrf PSTRCON
movlw b'00010000'
movwf OSCCON
- movlw b'11011111'
+ movlw b'00001111'
movwf TRISD
- bcf STATUS,RP0
-
+ movlw b'00100100'
+ movwf TXSTA
+ movlw .12
+ movwf SPBRG
+ clrf SPBRGH
+ movlw b'00100000'
+ movwf PIE1
+ clrf PIE2
+
;; bank 0
+ bcf STATUS,RP0
+ bcf STATUS,RP1
+ movlw b'10010000'
+ movwf RCSTA
+ movlw B'01000000'
+ movwf INTCON
+
bcf PORTD,TTX_RESET ;reset TTX
nop
nop
bsf PORTD,TTX_RESET
clrf TMR0
+ bsf INTCON,GIE
+ movlw .1
+ movwf TMP
goto main
;; -------------------------------------
@@ -111,13 +153,33 @@ init
;; -------------------------------------
;; SUBROUTINES
+uart_rx_byte
+ btfsc RCSTA,FERR
+ goto uart_rx_fe
+ movf RCREG,w ; TODO: move to input string
+ movwf TXREG
+ bsf TMP,0
+ return
- ;; TODO: add subroutines
+uart_rx_fe
+ movf RCREG,w
+ return
;; -------------------------------------
;; MAINLOOP
main
- goto powerdown
+ btfss TMP,0
+ goto main
+
+ bcf TMP,0
+ bcf PORTD,DTMF_PWRDWN
+ bcf INTCON,T0IF
+ clrf TMR0
+loop
+ btfss INTCON,T0IF
+ goto loop
+ bsf PORTD,DTMF_PWRDWN
+ goto main
powerdown
sleep