X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=teleterra.asm;h=ca459ad53765893ee0712fded4b4d64eeaa60ae3;hb=8851e7a9250b1d0206c12874914f3b4ecd925229;hp=629d42c057ae20b21ca4d4a973bb26805341e192;hpb=07a375434772e3b28d117420f91208cab4ac8ed1;p=hw%2Fteleterra diff --git a/teleterra.asm b/teleterra.asm index 629d42c..ca459ad 100644 --- a/teleterra.asm +++ b/teleterra.asm @@ -23,254 +23,254 @@ ; FIXME - more or less cloned from clock4robert project, not ready for use yet! - LIST P=18F886, R=DEC ; Use the PIC18F4550 and decimal system + LIST P=16F886, R=DEC ; Use the PIC18F4550 and decimal system #include "p16f886.inc" ; Include header file - __config 0x300001, 0x22 - __config 0x300003, 0xe - __config 0x300006, 0x81 - - CBLOCK 0x20 ; Declare variable addresses starting at 0x20 - Loop1,Loop2,Loop3,Counter - ENDC - -; ----------- -; Vectors -; ----------- - - ORG 0x0800 - GOTO Start - - ORG 0x0808 - CALL H_PRIO_ISR - RETFIE - - ORG 0x0818 - RETFIE - -; ----------- -; INITIALIZE -; ----------- - -Start - CLRF PORTA ; Initialize port A - CLRF PORTD ; Initialize port D - CLRF PORTE ; Initialize port E +; __config 0x300001, 0x22 +; __config 0x300003, 0xe +; __config 0x300006, 0x81 +; +; CBLOCK 0x20 ; Declare variable addresses starting at 0x20 +; Loop1,Loop2,Loop3,Counter +; ENDC +; +; ; ----------- +; ; Vectors +; ; ----------- +; +; ORG 0x0800 +; GOTO Start +; +; ORG 0x0808 +; CALL H_PRIO_ISR +; RETFIE +; +; ORG 0x0818 +; RETFIE +; +; ; ----------- +; ; INITIALIZE +; ; ----------- +; +; Start +; CLRF PORTA ; Initialize port A +; CLRF PORTD ; Initialize port D +; CLRF PORTE ; Initialize port E +; +; CLRF TRISA ; All pins port A output +; CLRF TRISD ; All pins port D output +; CLRF TRISE ; All pins port E output +; +; ; CLRF WDTCON +; +; ; ----------- +; ; Timer0 +; ; ----------- +; +; CLRF TMR0H ; clear timer 0 +; CLRF TMR0L +; +; ; this works out to about 1.4 seconds per tick +; ; MOVLW b'10000111' ; enable 16 bit timer, 256:1 prescaler +; ; this works out to about 350ms per tick +; ; MOVLW b'10000101' ; enable 16 bit timer, 64:1 prescaler +; ; this works out to about 10.4ms per tick, or 91.6hz +; ; MOVLW b'10000000' ; enable 16 bit timer, 2:1 prescaler +; ; this works out to 5.46ms per tick, 183.32hz +; MOVLW b'10001000' ; enable 16 bit timer, no prescaler +; MOVWF T0CON +; +; BCF INTCON, TMR0IF ; clear Timer0 interrupt flag +; BSF INTCON, TMR0IE ; enable Timer0 interrupt +; BSF INTCON, GIE ; enable interrupts +; +; ; ------------------------ +; ; FUNCTION OF PORT A PINS +; ; ------------------------ +; ; +; ; MOVLW 7 +; ; MOVWF CMCON ; Comparators off, all pins digital I/O +; ; +; ; ---------- +; ; MAIN LOOP +; ; ---------- +; Main CALL LpmOn ; light PM +; CALL LamOff +; CALL LsaOn ; light segment A +; CALL LsbOn ; light segment B +; CALL LscOn ; light segment C +; CALL LsdOn ; light segment D +; CALL LseOn ; light segment E +; CALL LsfOn ; light segment F +; CALL LsgOn ; light segment G +; CALL LcOn ; colon on +; CALL Drv0On +; CALL Drv1Off +; CALL Drv2Off +; CALL Drv3Off +; CALL delay +; CALL LcOff ; colon off +; CALL Drv0Off +; CALL Drv1On +; CALL Drv2Off +; CALL Drv3Off +; CALL delay +; CALL LcOn ; colon on +; CALL LamOn +; CALL LpmOff +; CALL Drv0Off +; CALL Drv1Off +; CALL Drv2On +; CALL Drv3Off +; CALL delay +; CALL LcOff ; colon off +; CALL Drv0Off +; CALL Drv1Off +; CALL Drv2Off +; CALL Drv3On +; CALL delay +; GOTO Main +; +; ; digit select 0 +; Drv0On BSF LATA,2 +; RETURN +; +; Drv0Off BCF LATA,2 +; RETURN +; +; ; digit select 1 +; Drv1On BSF LATA,3 +; RETURN +; +; Drv1Off BCF LATA,3 +; RETURN +; +; ; digit select 2 +; Drv2On BSF LATA,4 +; RETURN +; +; Drv2Off BCF LATA,4 +; RETURN +; +; ; digit select 3 +; Drv3On BSF LATA,5 +; RETURN +; +; Drv3Off BCF LATA,5 +; RETURN +; +; ; control digit segment A +; LsaOn BSF LATD,0 +; RETURN +; +; LsaOff BCF LATD,0 +; RETURN +; +; ; control digit segment B +; LsbOn BSF LATD,1 +; RETURN +; +; LsbOff BCF LATD,1 +; RETURN +; +; ; control digit segment C +; LscOn BSF LATD,2 +; RETURN +; +; LscOff BCF LATD,2 +; RETURN +; +; ; control digit segment D +; LsdOn BSF LATD,3 +; RETURN +; +; LsdOff BCF LATD,3 +; RETURN +; +; ; control digit segment E +; LseOn BSF LATD,4 +; RETURN +; +; LseOff BCF LATD,4 +; RETURN +; +; ; control digit segment F +; LsfOn BSF LATD,5 +; RETURN +; +; LsfOff BCF LATD,5 +; RETURN +; +; ; control digit segment G +; LsgOn BSF LATD,6 +; RETURN +; +; LsgOff BCF LATD,6 +; RETURN +; +; ; control the "AM" LED +; LamOn BSF LATE,1 +; RETURN +; +; LamOff BCF LATE,1 +; RETURN +; +; ; control the "PM" LED +; LpmOn BSF LATE,2 +; RETURN +; +; LpmOff BCF LATE,2 +; RETURN +; +; ; control the "colon" LED +; LcOn BSF LATD,7 +; RETURN +; +; LcOff BCF LATD,7 +; RETURN +; +; ; control the "alarm" LED +; LaOn BSF LATE,0 +; RETURN +; +; LaOff BCF LATE,0 +; RETURN +; +; ; --------------- +; ; DELAY 0.5 SEC +; ; --------------- +; ; +; ;delay MOVLW 20 +; delay MOVLW 10 +; MOVWF Loop1 +; Outer MOVLW 250 +; MOVWF Loop2 +; Middle MOVLW 239 +; MOVWF Loop3 +; Inner NOP +; NOP +; DECFSZ Loop3,F +; GOTO Inner +; DECFSZ Loop2,F +; GOTO Middle +; DECFSZ Loop1,F +; GOTO Outer +; RETURN +; +; ; --------------- +; ; High priority interrupt service route +; ; --------------- +; H_PRIO_ISR +; BCF INTCON, TMR0IF ; clear Timer0 interrupt flag +; INCF Counter,1 +; BTFSC Counter,6 ; test bit 6 +; GOTO TurnItOn +; CALL LaOff ; turn alarm LED off +; GOTO End_ISR +; TurnItOn +; CALL LaOn ; turn alarm LED on +; End_ISR +; RETURN - CLRF TRISA ; All pins port A output - CLRF TRISD ; All pins port D output - CLRF TRISE ; All pins port E output - -; CLRF WDTCON - -; ----------- -; Timer0 -; ----------- - - CLRF TMR0H ; clear timer 0 - CLRF TMR0L - -; this works out to about 1.4 seconds per tick -; MOVLW b'10000111' ; enable 16 bit timer, 256:1 prescaler -; this works out to about 350ms per tick -; MOVLW b'10000101' ; enable 16 bit timer, 64:1 prescaler -; this works out to about 10.4ms per tick, or 91.6hz -; MOVLW b'10000000' ; enable 16 bit timer, 2:1 prescaler -; this works out to 5.46ms per tick, 183.32hz - MOVLW b'10001000' ; enable 16 bit timer, no prescaler - MOVWF T0CON - - BCF INTCON, TMR0IF ; clear Timer0 interrupt flag - BSF INTCON, TMR0IE ; enable Timer0 interrupt - BSF INTCON, GIE ; enable interrupts - -; ------------------------ -; FUNCTION OF PORT A PINS -; ------------------------ -; -; MOVLW 7 -; MOVWF CMCON ; Comparators off, all pins digital I/O -; -; ---------- -; MAIN LOOP -; ---------- -Main CALL LpmOn ; light PM - CALL LamOff - CALL LsaOn ; light segment A - CALL LsbOn ; light segment B - CALL LscOn ; light segment C - CALL LsdOn ; light segment D - CALL LseOn ; light segment E - CALL LsfOn ; light segment F - CALL LsgOn ; light segment G - CALL LcOn ; colon on - CALL Drv0On - CALL Drv1Off - CALL Drv2Off - CALL Drv3Off - CALL delay - CALL LcOff ; colon off - CALL Drv0Off - CALL Drv1On - CALL Drv2Off - CALL Drv3Off - CALL delay - CALL LcOn ; colon on - CALL LamOn - CALL LpmOff - CALL Drv0Off - CALL Drv1Off - CALL Drv2On - CALL Drv3Off - CALL delay - CALL LcOff ; colon off - CALL Drv0Off - CALL Drv1Off - CALL Drv2Off - CALL Drv3On - CALL delay - GOTO Main - -; digit select 0 -Drv0On BSF LATA,2 - RETURN - -Drv0Off BCF LATA,2 - RETURN - -; digit select 1 -Drv1On BSF LATA,3 - RETURN - -Drv1Off BCF LATA,3 - RETURN - -; digit select 2 -Drv2On BSF LATA,4 - RETURN - -Drv2Off BCF LATA,4 - RETURN - -; digit select 3 -Drv3On BSF LATA,5 - RETURN - -Drv3Off BCF LATA,5 - RETURN - -; control digit segment A -LsaOn BSF LATD,0 - RETURN - -LsaOff BCF LATD,0 - RETURN - -; control digit segment B -LsbOn BSF LATD,1 - RETURN - -LsbOff BCF LATD,1 - RETURN - -; control digit segment C -LscOn BSF LATD,2 - RETURN - -LscOff BCF LATD,2 - RETURN - -; control digit segment D -LsdOn BSF LATD,3 - RETURN - -LsdOff BCF LATD,3 - RETURN - -; control digit segment E -LseOn BSF LATD,4 - RETURN - -LseOff BCF LATD,4 - RETURN - -; control digit segment F -LsfOn BSF LATD,5 - RETURN - -LsfOff BCF LATD,5 - RETURN - -; control digit segment G -LsgOn BSF LATD,6 - RETURN - -LsgOff BCF LATD,6 - RETURN - -; control the "AM" LED -LamOn BSF LATE,1 - RETURN - -LamOff BCF LATE,1 - RETURN - -; control the "PM" LED -LpmOn BSF LATE,2 - RETURN - -LpmOff BCF LATE,2 - RETURN - -; control the "colon" LED -LcOn BSF LATD,7 - RETURN - -LcOff BCF LATD,7 - RETURN - -; control the "alarm" LED -LaOn BSF LATE,0 - RETURN - -LaOff BCF LATE,0 - RETURN - -; --------------- -; DELAY 0.5 SEC -; --------------- -; -;delay MOVLW 20 -delay MOVLW 10 - MOVWF Loop1 -Outer MOVLW 250 - MOVWF Loop2 -Middle MOVLW 239 - MOVWF Loop3 -Inner NOP - NOP - DECFSZ Loop3,F - GOTO Inner - DECFSZ Loop2,F - GOTO Middle - DECFSZ Loop1,F - GOTO Outer - RETURN - -; --------------- -; High priority interrupt service route -; --------------- -H_PRIO_ISR - BCF INTCON, TMR0IF ; clear Timer0 interrupt flag - INCF Counter,1 - BTFSC Counter,6 ; test bit 6 - GOTO TurnItOn - CALL LaOff ; turn alarm LED off - GOTO End_ISR -TurnItOn - CALL LaOn ; turn alarm LED on -End_ISR - RETURN - - END + END