summaryrefslogtreecommitdiff
path: root/software
diff options
context:
space:
mode:
authorChristian Pointner <equinox@mur.at>2011-12-09 23:34:31 +0000
committerChristian Pointner <equinox@mur.at>2011-12-09 23:34:31 +0000
commitef60fb6572d4d2be94ebdc3a85543663af627fd1 (patch)
treebf1e87a2e0c63c7731474a77a22edee8c2ea29a2 /software
parentplot of solarcell U/I measurements (diff)
added CTS
git-svn-id: https://svn.spreadspace.org/mur.sat@212 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software')
-rw-r--r--software/idm/idm.asm111
1 files changed, 94 insertions, 17 deletions
diff --git a/software/idm/idm.asm b/software/idm/idm.asm
index a4fd653..3dc9538 100644
--- a/software/idm/idm.asm
+++ b/software/idm/idm.asm
@@ -46,9 +46,12 @@ BUF_OFFSET EQU H'0020'
UNDERRUN EQU .0
OVERRUN EQU .1
+CTS EQU .7
+
;; I/O Pins
;; PortA
-MPU_INT EQU .4
+DBG1 EQU .4
+DBG2 EQU .5
;; PortC
@@ -57,7 +60,7 @@ MPU_INT EQU .4
;; all pages
-TMP EQU H'0070'
+RX_BYTE EQU H'0070'
WAIT_CNT EQU H'0071'
FLAGS EQU H'0072'
@@ -92,13 +95,20 @@ STATUS_TEMP EQU H'007F'
goto int_tmr2
btfsc PIR1,RCIF
goto int_uart_rx
+ btfsc PIR1,TXIF
+ goto int_uart_tx
goto interrupt_end
int_tmr2
-; movlw b'00010000'
-; xorwf PORTA,f
-
bsf ADCON0,GO
+
+ bsf STATUS,RP0
+ btfss FLAGS,CTS
+ bcf PIE1,TXIE
+ btfsc FLAGS,CTS
+ bsf PIE1,TXIE
+ bcf STATUS,RP0
+
int_tmr2_adcon
btfsc ADCON0,GO
goto int_tmr2_adcon
@@ -108,12 +118,21 @@ int_tmr2_adcon
goto int_tmr2_end
movf ADRESH,w
movwf INDF
- movwf TXREG
-
+
int_tmr2_end
bcf PIR1,TMR2IF
goto interrupt_end
+
+int_uart_tx
+ call rbuf_next
+ btfsc FLAGS,UNDERRUN
+ goto interrupt_end
+ movf INDF,w
+ movwf TXREG
+ goto interrupt_end
+
+
int_uart_rx
call uart_rx_byte
btfsc PIR1,RCIF
@@ -151,9 +170,9 @@ init
;; bank 2
bcf STATUS,RP0
bsf STATUS,RP1
- movlw b'10100000'
+ movlw b'10000000'
movwf CM1CON0
- movlw b'10110000'
+ movlw b'10010000'
movwf CM2CON0
;; bank 1
@@ -182,7 +201,7 @@ init
clrf PIE2
; movlw .250 ;; 8kHz
movlw .200 ;; 5kHz
-; movlw .156 ;; ~50Hz
+; movlw .156 ;; ~50Hz / ~200Hz
movwf PR2
clrf ADCON1
@@ -194,6 +213,7 @@ init
; movlw b'00000100' ;; 8kHz
movlw b'00001100' ;; 5kHz
; movlw b'01111110' ;; ~50Hz
+; movlw b'01111101' ;; ~200Hz
movwf T2CON
movlw b'01000000'
movwf INTCON
@@ -201,11 +221,12 @@ init
movlw b'10010101'
movwf ADCON0
-; bcf PORTA,MPU_INT
+ bcf PORTA,DBG1
+ bcf PORTA,DBG2
call wbuf_reset
call rbuf_reset
- clrf TMP
+ clrf RX_BYTE
bsf INTCON,GIE
goto main
@@ -253,7 +274,7 @@ uart_rx_byte
btfsc RCSTA,FERR
goto uart_rx_fe
movf RCREG,w ; TODO: move to input string
- movwf TMP
+ movwf RX_BYTE
return
uart_rx_fe
@@ -267,6 +288,8 @@ wbuf_reset
movlw BUF_PAGE_CNT - 1
movwf WBUF_PAGE_NUM
bcf FLAGS,OVERRUN
+ bcf PORTA,DBG1
+
;; -------------------
wbuf_next
@@ -284,10 +307,18 @@ wbuf_next
goto wbuf_move_ptr
bsf FLAGS,OVERRUN
+ bsf PORTA,DBG1
+
return
wbuf_move_ptr
bcf FLAGS,UNDERRUN
+ bcf PORTA,DBG2
+ bsf STATUS,RP0
+ btfsc FLAGS,CTS
+ bsf PIE1,TXIE
+ bcf STATUS,RP0
+
movf WBUF_PAGE_PTR,f
btfsc STATUS,Z
goto wbuf_next_page
@@ -329,6 +360,13 @@ rbuf_reset
movlw BUF_PAGE_CNT - 1
movwf RBUF_PAGE_NUM
bsf FLAGS,UNDERRUN
+ bsf PORTA,DBG2
+
+ bsf STATUS,RP0
+ bcf PIE1,TXIE
+ bcf STATUS,RP0
+
+ bcf FLAGS,CTS
;; -------------------
rbuf_next
@@ -346,10 +384,17 @@ rbuf_next
goto rbuf_move_ptr
bsf FLAGS,UNDERRUN
+ bsf PORTA,DBG2
+ bsf STATUS,RP0
+ bcf PIE1,TXIE
+ bcf STATUS,RP0
+
return
rbuf_move_ptr
bcf FLAGS,OVERRUN
+ bcf PORTA,DBG1
+
movf RBUF_PAGE_PTR,f
btfsc STATUS,Z
goto rbuf_next_page
@@ -388,10 +433,42 @@ rbuf_fill_fsr
;; -------------------------------------
;; MAINLOOP
main
- ;; movf TMP,f
- ;; btfsc STATUS,Z
- ;; goto main
-
+ movlw 'r'
+ xorwf RX_BYTE,w
+ btfsc STATUS,Z
+ goto cmd_read
+ movlw 'n'
+ xorwf RX_BYTE,w
+ btfsc STATUS,Z
+ goto cmd_noread
+ movlw 's'
+ xorwf RX_BYTE,w
+ btfsc STATUS,Z
+ goto cmd_start
+ movlw 'p'
+ xorwf RX_BYTE,w
+ btfsc STATUS,Z
+ goto cmd_stop
+ goto main
+
+cmd_read
+ bsf FLAGS,CTS
+ clrf RX_BYTE
+ goto main
+
+cmd_noread
+ bcf FLAGS,CTS
+ clrf RX_BYTE
+ goto main
+
+cmd_start
+ ;; start sampling
+ ;; bsf FLAGS,CTS
+ clrf RX_BYTE
+ goto main
+
+cmd_stop
+ clrf RX_BYTE
goto main
powerdown