diff options
author | Christian Pointner <equinox@mur.at> | 2011-12-09 12:44:22 +0000 |
---|---|---|
committer | Christian Pointner <equinox@mur.at> | 2011-12-09 12:44:22 +0000 |
commit | a5fa6cd3e8abb7082b044b438b19527072d7fd6d (patch) | |
tree | d4d4d15a5378fec16bb094b1204499a4f5f02bd8 /software/idm/idm.asm | |
parent | idm as simple sound card (diff) |
added write ring buffer
git-svn-id: https://svn.spreadspace.org/mur.sat@209 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software/idm/idm.asm')
-rw-r--r-- | software/idm/idm.asm | 114 |
1 files changed, 91 insertions, 23 deletions
diff --git a/software/idm/idm.asm b/software/idm/idm.asm index 86bffae..c1a3ed3 100644 --- a/software/idm/idm.asm +++ b/software/idm/idm.asm @@ -38,7 +38,10 @@ ;; ------------------------------------- ;; DEFINES ;; constants - +BUF_PAGE_LEN EQU H'0050' +BUF_PAGE_CNT EQU H'0004' +BUF_OFFSET EQU H'0020' + ;; I/O Pins ;; PortA MPU_INT EQU .4 @@ -47,12 +50,17 @@ MPU_INT EQU .4 ;; variables ;; page 0 only -TMP EQU H'0020' -WAIT_CNT EQU H'0021' ;; all pages -FSR_TEMP EQU H'007D' +TMP EQU H'0070' +WAIT_CNT EQU H'0071' + +WBUF_PAGE_PTR EQU H'0074' +WBUF_PAGE_NUM EQU H'0075' +RBUF_PAGE_PTR EQU H'0076' +RBUF_PAGE_NUM EQU H'0077' + W_TEMP EQU H'007E' STATUS_TEMP EQU H'007F' @@ -70,8 +78,6 @@ STATUS_TEMP EQU H'007F' movwf W_TEMP swapf STATUS,W movwf STATUS_TEMP - movf FSR,w - movwf FSR_TEMP bcf STATUS,RP0 bcf STATUS,RP1 @@ -84,16 +90,18 @@ STATUS_TEMP EQU H'007F' goto interrupt_end int_tmr2 - movlw b'00010000' - xorwf PORTA,f +; movlw b'00010000' +; xorwf PORTA,f bsf ADCON0,GO int_tmr2_adcon btfsc ADCON0,GO goto int_tmr2_adcon + call wbuf_next movf ADRESH,w - movwf TXREG + movwf IND +; movwf TXREG bcf PIR1,TMR2IF goto interrupt_end @@ -115,8 +123,6 @@ int_uart_rx_oe interrupt_end ;; restore context - movf FSR_TEMP,w - movwf FSR swapf STATUS_TEMP,W movwf STATUS swapf W_TEMP,F @@ -145,7 +151,7 @@ init ;; bank 1 bsf STATUS,RP0 bcf STATUS,RP1 - movlw b'10000000' + movlw b'10000010' movwf OPTION_REG clrf PSTRCON movlw b'01111000' @@ -166,7 +172,9 @@ init movlw b'00100010' movwf PIE1 clrf PIE2 - movlw .200 +; movlw .250 ;; 8kHz +; movlw .200 ;; 5kHz + movlw .156 ;; ~50Hz movwf PR2 clrf ADCON1 @@ -175,7 +183,9 @@ init bcf STATUS,RP1 movlw b'10010000' movwf RCSTA - movlw b'00001100' +; movlw b'00000100' ;; 8kHz +; movlw b'00001100' ;; 5kHz + movlw b'01111110' ;; ~50Hz movwf T2CON movlw b'01000000' movwf INTCON @@ -183,7 +193,12 @@ init movlw b'10010101' movwf ADCON0 - bcf PORTA,MPU_INT +; bcf PORTA,MPU_INT + + movlw BUF_PAGE_LEN - 1 + movwf WBUF_PAGE_PTR + movlw BUF_PAGE_CNT - 1 + movwf WBUF_PAGE_NUM clrf TMP bsf INTCON,GIE @@ -192,11 +207,33 @@ init ;; ------------------------------------- + ;; TABLES +digit + addwf PCL,f + retlw '0' + retlw '1' + retlw '2' + retlw '3' + retlw '4' + retlw '5' + retlw '6' + retlw '7' + retlw '8' + retlw '9' + retlw 'A' + retlw 'B' + retlw 'C' + retlw 'D' + retlw 'E' + retlw 'F' + + + ;; ------------------------------------- ;; SUBROUTINES wait_ms movwf WAIT_CNT wait_next - movlw .9 + movlw .6 movwf TMR0 bcf INTCON,T0IF wait_loop @@ -206,7 +243,7 @@ wait_loop goto wait_next return - ;; ------------------------------------- + ;; ------------------- uart_rx_byte btfsc RCSTA,FERR goto uart_rx_fe @@ -218,18 +255,49 @@ uart_rx_fe movf RCREG,w return + ;; ------------------- +wbuf_next + movf WBUF_PAGE_PTR,f + btfsc STATUS,Z + goto wbuf_next_page + decf WBUF_PAGE_PTR,f + goto wbuf_fill_fsr + +wbuf_next_page + movlw BUF_PAGE_LEN - 1 + movwf WBUF_PAGE_PTR + movf WBUF_PAGE_NUM,f + btfsc STATUS,Z + goto wbuf_next_cycle + decf WBUF_PAGE_NUM,f + goto wbuf_fill_fsr + +wbuf_next_cycle + movlw BUF_PAGE_CNT - 1 + movwf WBUF_PAGE_NUM + +wbuf_fill_fsr + movlw BUF_OFFSET + addwf WBUF_PAGE_PTR,w + movwf FSR + + btfss WBUF_PAGE_NUM,0 + bcf FSR,7 + btfsc WBUF_PAGE_NUM,0 + bsf FSR,7 + btfss WBUF_PAGE_NUM,1 + bcf STATUS,IRP + btfsc WBUF_PAGE_NUM,1 + bsf STATUS,IRP + return + ;; ------------------------------------- ;; MAINLOOP main ;; movf TMP,f ;; btfsc STATUS,Z ;; goto main - - ;; movlw '.' - ;; movwf TXREG - ;; movlw .255 - ;; call wait_ms - + goto main powerdown |