diff options
author | Christian Pointner <equinox@mur.at> | 2011-05-28 00:37:38 +0000 |
---|---|---|
committer | Christian Pointner <equinox@mur.at> | 2011-05-28 00:37:38 +0000 |
commit | 2544830b8b30a033287a1e14db54853181c026e1 (patch) | |
tree | d01515cc50080ba5925d4407f838edafc801baf0 /software/ttx/ttx.asm | |
parent | ported code to 12F519 (diff) |
ported code to PIC12F635 (not tested yet)
git-svn-id: https://svn.spreadspace.org/mur.sat@29 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software/ttx/ttx.asm')
-rw-r--r-- | software/ttx/ttx.asm | 147 |
1 files changed, 92 insertions, 55 deletions
diff --git a/software/ttx/ttx.asm b/software/ttx/ttx.asm index 7931771..805d0f4 100644 --- a/software/ttx/ttx.asm +++ b/software/ttx/ttx.asm @@ -30,48 +30,97 @@ ;; ------------------------------------- ;; PREAMBLE - LIST p=12F519 - include "p12f519.inc" - ;; __config _IntRC_OSC & _IOSCFS_4MHz & _MCLRE_ON & _CP_OFF & _CPDF_OFF & _WDTE_OFF - __config _IntRC_OSC & _IOSCFS_4MHz & _MCLRE_OFF & _CP_OFF & _CPDF_OFF & _WDTE_OFF + 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 ;; ------------------------------------- ;; DEFINES -BEACON_INT EQU .5 -SECCNT EQU H'0007' +BEACON_INT EQU .3 ; *2 = Beacon Interval in seconds +SECCNT EQU H'0040' -CHAR EQU H'0008' -CHARCNT EQU H'0009' -ELEMENT EQU H'000A' -ELECNT EQU H'000B' +CHAR EQU H'0041' +CHARCNT EQU H'0042' +ELEMENT EQU H'0043' +ELECNT EQU H'0044' -DOT EQU .85 -DASH EQU .255 -ESPACE EQU .85 -CSPACE EQU .255 -CWSPEED EQU .100 -DOTCNT0 EQU H'000E' -DOTCNT1 EQU H'000F' +DOT EQU .256 - .29 +DASH EQU .256 - .87 +ESPACE EQU .256 - .29 +CSPACE EQU .256 - .87 +WSPACE EQU .256 - .203 + +CWENABLE EQU GP0 +CWOUT EQU GP1 +SCLK EQU GP2 +SDAT EQU GP4 + +W_TEMP EQU H'007E' +STATUS_TEMP EQU H'007F' -CWENABLE EQU 0 -CWOUT EQU 1 - ;; ------------------------------------- - ;; OFFSET + ;; Reset Vector org 0 + goto init + + ;; ------------------------------------- + ;; Interrupt Vector + org 4 + ;; save context + movwf W_TEMP + swapf STATUS,W + movwf STATUS_TEMP + + btfss INTCON,INTF + goto tmr1_int +ext_int + ;; TODO: read bit from GPIO,SDAT and add to received string + goto interrupt_end + +tmr1_int + decf SECCNT,f + +interrupt_end + ;; restore context + swapf STATUS_TEMP,W + movwf STATUS + swapf W_TEMP,F + swapf W_TEMP,W + retfie ;; ------------------------------------- ;; INIT init - movlw b'11110110' - option + ;; bank 1 + bsf STATUS,RP0 + bcf STATUS,RP1 + + movlw b'10000101' + movwf OPTION_REG movlw b'11111100' - tris PORTB - bcf PORTB,CWOUT - bcf PORTB,CWENABLE - clrf TMR0 + movwf TRISIO + movlw b'10000001' + movwf PIE1 + movlw b'00001000' + movwf OSCCON + + bcf STATUS,RP0 + + ;; bank 0 + movlw b'01010000' + movwf INTCON + movlw b'00000111' + movwf T1CON + movlw b'00000111' + movwf CMCON0 + + bcf GPIO,CWOUT + bcf GPIO,CWENABLE + movlw BEACON_INT movwf SECCNT + + bsf INTCON,GIE goto main ;; ------------------------------------- @@ -218,23 +267,16 @@ string ;; ------------------------------------- ;; SUBROUTINES dottime - movwf DOTCNT1 -dot_outer - movlw CWSPEED - movwf DOTCNT0 + movwf TMR0 + bcf INTCON,T0IF dot_inner - nop - nop - nop - nop - decfsz DOTCNT0,f + btfss INTCON,T0IF goto dot_inner - decfsz DOTCNT1,f - goto dot_outer return ;; ------------------------------------- send_beacon + bsf GPIO,CWENABLE movlw .7 movwf CHARCNT @@ -252,13 +294,13 @@ beacon_next_char goto beacon_invalid_char beacon_next_element - bsf PORTB,CWOUT + bsf GPIO,CWOUT btfss ELEMENT,7 movlw DOT btfsc ELEMENT,7 movlw DASH call dottime - bcf PORTB,CWOUT + bcf GPIO,CWOUT rlf ELEMENT,f @@ -270,6 +312,7 @@ beacon_next_element beacon_invalid_char decfsz CHARCNT,f goto beacon_next_char + bcf GPIO,CWENABLE return beacon_element_space @@ -280,27 +323,21 @@ beacon_element_space ;; ------------------------------------- ;; MAINLOOP main - movf TMR0,w + ;; this gets called after reset and whenever a wakeup occured + ;; (after TMR1 overrun or interrupt on GP2) + movf SECCNT,f btfss STATUS,Z - goto main + goto powerdown - ;; this gets called every second - decfsz SECCNT,f - goto waitfor0 + ;; this gets called every BEACON_INT*2 seconds movlw BEACON_INT movwf SECCNT - - ;; this gets called every BEACON_INT seconds call send_beacon - - ;; is the timer above zero? -waitfor0 - movf TMR0,w - btfsc STATUS,Z - goto waitfor0 - - goto main +powerdown + sleep + goto main + ;; ------------------------------------- ;; END end |