diff options
author | Christian Pointner <equinox@mur.at> | 2012-02-04 00:02:51 +0000 |
---|---|---|
committer | Christian Pointner <equinox@mur.at> | 2012-02-04 00:02:51 +0000 |
commit | 3a7eea4c70cd14809243f2092ac36f7a35711947 (patch) | |
tree | 4e3499beea28d4063db24957700b285c7fef39e3 | |
parent | try slower mode for ihu-ttx communcation (diff) |
moved beacon interval to timer1 (async)
git-svn-id: https://svn.spreadspace.org/mur.sat@243 7de4ea59-55d0-425e-a1af-a3118ea81d4c
-rw-r--r-- | software/ttx/ttx.asm | 128 |
1 files changed, 69 insertions, 59 deletions
diff --git a/software/ttx/ttx.asm b/software/ttx/ttx.asm index 1580f34..8c3015e 100644 --- a/software/ttx/ttx.asm +++ b/software/ttx/ttx.asm @@ -32,7 +32,8 @@ LIST p=12F635 include "p12f635.inc" - __config _WUREN_OFF & _FCMEN_OFF & _IESO_OFF & _BOD_OFF & _CPD_OFF & _CP_OFF & _MCLRE_ON & _PWRTE_OFF & _WDT_ON & _INTRC_OSC_NOCLKOUT + ;;__config _WUREN_OFF & _FCMEN_OFF & _IESO_OFF & _BOD_OFF & _CPD_OFF & _CP_OFF & _MCLRE_ON & _PWRTE_OFF & _WDT_ON & _INTRC_OSC_NOCLKOUT + __config _WUREN_OFF & _FCMEN_OFF & _IESO_OFF & _BOD_OFF & _CPD_OFF & _CP_OFF & _MCLRE_ON & _PWRTE_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT ;; ------------------------------------- ;; DEFINES @@ -42,7 +43,8 @@ DOT_DEF EQU .256 - .21 ; .29 DASH_DEF EQU .256 - .63 ; .87 WSPACE_DEF EQU .256 - .147 ; .203 TUNE_DEF EQU DOT_DEF -BCONINT_DEF EQU .120 +BCNINTL_DEF EQU .256 - .120 +BCNINTH_DEF EQU .255 START_CHAR EQU 'N' ACK_CHAR EQU 'A' OSC_LOW EQU b'00000000' @@ -69,37 +71,39 @@ ACK_DATA EQU H'0048' TMP1 EQU H'0049' TMP2 EQU H'004A' -RX_STATE EQU H'004B' -RX_FSR_TMP EQU H'004C' -RX_CSUM EQU H'004D' -RX_BIT_CNT EQU H'004E' -RX_BYTE_CNT EQU H'004F' +RX_FSR_TMP EQU H'004B' +RX_CSUM EQU H'004C' +RX_BIT_CNT EQU H'004D' +RX_BYTE_CNT EQU H'004E' +RX_DLEN EQU H'004F' RX_CMD EQU H'0050' RX_D_START EQU H'0051' RX_D_END EQU H'005F' ;; all pages -BEACON_INT EQU H'0070' -DOT EQU H'0071' +BEACON_INTL EQU H'0070' +BEACON_INTH EQU H'0071' +DOT EQU H'0072' ESPACE EQU DOT -DASH EQU H'0072' +DASH EQU H'0073' CSPACE EQU DASH -WSPACE EQU H'0073' -TUNE EQU H'0074' - +WSPACE EQU H'0074' +TUNE EQU H'0075' + NVSTATE EQU H'007A' BEACONCNTH EQU H'007B' BEACONCNTL EQU H'007C' -SECCNT EQU H'007D' +STATE EQU H'007D' W_TEMP EQU H'007E' STATUS_TEMP EQU H'007F' + ;; bits STATE +startbeacon EQU .0 +rxcomplete EQU .1 + ;; bits NVSTATE safe EQU .0 - ;; bits RX_STATE -complete EQU .7 - ;; ------------------------------------- ;; Reset Vector org .0 @@ -114,10 +118,10 @@ complete EQU .7 movwf STATUS_TEMP btfss INTCON,INTF - goto clk_1hz_int + goto beacon_int_int ext_int bcf INTCON,INTF - btfsc RX_STATE,complete + btfsc STATE,rxcomplete goto interrupt_end bsf STATUS,RP0 movlw OSC_HIGH @@ -134,7 +138,7 @@ ext_int movlw b'00001111' andwf RX_CMD,w movwf RX_BYTE_CNT - movwf RX_STATE + movwf RX_DLEN btfsc STATUS,Z goto ext_int_send_csum @@ -158,26 +162,24 @@ ext_int_wait_ack_high btfss GPIO,SCLK goto ext_int_wait_ack_high btfss GPIO,SDAT - bsf RX_STATE,complete + bsf STATE,rxcomplete bsf STATUS,RP0 movlw OSC_LOW movwf OSCCON ;; back on low OSC goto interrupt_end - -clk_1hz_int + +beacon_int_int bcf STATUS,RP0 - btfss GPIO,CLK_1HZ - goto clk_1hz_int_low - bcf INTCON,RAIF - goto interrupt_end - -clk_1hz_int_low - movf SECCNT,f - btfss STATUS,Z - decf SECCNT,f - bcf INTCON,RAIF + bcf T1CON,TMR1ON + movf BEACON_INTL,w + movwf TMR1L + movf BEACON_INTH,w + movwf TMR1H + bsf T1CON,TMR1ON + bcf PIR1,TMR1IF + bsf STATE,startbeacon goto interrupt_end interrupt_end @@ -378,31 +380,38 @@ init movwf TRISIO movlw OSC_LOW movwf OSCCON - movlw b'00100000' - movwf IOCA + movlw b'00000001' + movwf PIE1 bcf STATUS,RP0 ;; bank 0 - movlw b'00010110' - movwf WDTCON - movlw b'00011000' + ;; movlw b'00010110' ; TODO: watchdog?? + ;; movwf WDTCON + movlw b'01010000' movwf INTCON movlw b'00000111' movwf CMCON0 - + movlw b'00000010' + movwf CMCON1 + movlw b'00000110' + movwf T1CON + bcf GPIO,CWOUT bcf GPIO,CWENABLE - clrf RX_STATE + clrf RX_DLEN + bcf STATE,rxcomplete clrf NVSTATE ; TODO: read State from EEPROM movlw .42 movwf BEACONCNTL ; TODO: read Beaconcnt from EEPROM movlw .23 movwf BEACONCNTH - movlw BCONINT_DEF ; TODO: read Beacon Interval from EEPROM - movwf BEACON_INT + movlw BCNINTL_DEF ; TODO: read Beacon Interval from EEPROM + movwf BEACON_INTL + movlw BCNINTH_DEF + movwf BEACON_INTH movlw DOT_DEF ; TODO: read cw timings from EEPROM movwf DOT ; - DOT: length of . @@ -412,10 +421,13 @@ init movwf WSPACE movlw TUNE_DEF movwf TUNE - - ;; movf BEACON_INT,w - ;; movwf SECCNT - clrf SECCNT + + movf BEACON_INTL,w + movwf TMR1L + movf BEACON_INTH,w + movwf TMR1H + bcf STATE,startbeacon + bsf T1CON,TMR1ON bsf INTCON,GIE goto main @@ -762,7 +774,7 @@ send_ack movlw RX_CMD movwf FSR bcf STATUS,IRP - movf RX_STATE,w + movf RX_DLEN,w andlw b'00001111' movwf TMP1 btfsc STATUS,Z @@ -791,27 +803,25 @@ ack_parity ;; MAINLOOP main ;; this gets called after reset and whenever a wakeup occured - ;; (after GP5 change or interrupt on GP2) - movf SECCNT,f - btfsc STATUS,Z - goto seccnt_zero - btfsc RX_STATE,complete + ;; (after timer1 overflow or interrupt on GP2) + btfsc STATE,startbeacon + goto beaconint_elapsed + btfsc STATE,rxcomplete goto msg_received goto powerdown - ;; this gets called every BEACON_INT seconds -seccnt_zero - movf BEACON_INT,w - movwf SECCNT - btfss NVSTATE,safe + ;; this gets called every beacon interval +beaconint_elapsed + bcf STATE,startbeacon + ;; btfss NVSTATE,safe ;; call send_beacon goto powerdown ;; this gets called whenever a message was received from ihu msg_received + bcf STATE,rxcomplete ;; call send_ack - bcf RX_STATE,complete - clrf RX_STATE + clrf RX_DLEN powerdown sleep |