; Filename : MULTI_U1.asm ; MultiDisplay program for U1 chip ( 16C773 : 36 LED pelorus display ) ; This program accepts an RS232 message in the UART and interpets the ; message to drive a pelorus Doppler display. The pelorus is organised ; into 6 banks with 6 LEDs per bank. ( 36 total, 10 degrees / LED ) ; This program also generates a pulse train output which drives a ; second PIC chip on the same board. The second PIC chip drives a 3-digit ; numeric readout, displaying the same data in numeric form. ; Several "straps" are examined at "power on" time, to configure the ; UART for different baud rates and parameters. Additional straps are ; examined in "realtime" and are described below. ; If no data is recieved in 3 seconds and the "hold" strap is tied to ; ground, the pelorus display will "orbit" at a rate of approx once ; per second to indicate no valid data is available. If the "hold" ; strap is tied to +5V, the last valid data will be displayed instead, ; but it will be "blinked" 4 times per second, to indicate the display ; is not being updated. ; The "format" strap is only active if the DF is generating an "extended ; Agrello format" message. Grounding this strap will cause the display to ; show relative bearings. Tying this strap to +5v will cause the display ; to show magnetic bearings. ( only works with my DF, with the compass ; option installed, and DOPPLER2 PIC code ) ; To facilitate night viewing, the entire pelorus display is "blinked" ; about once per second, to provide a context for the LED indicating the ; present DF bearing. ; The numeric output to the 16F84 chip consists of two wires. One is ; a data "gate" and the other is a data "clock". When data is sent to ; the 16F84, data gate goes high to signal the 16F84 that fresh data will ; soon be transmitted. Data clock then generates a series of pulses while ; data gate remains high. The number of clock pulses equals the ( binary ) ; DF bearing. When the pulses are completed, data gate goes low to ; signal that data transmission is completed. ; Valid DF data numbers range from 000 to 359. If valid data is not ; available, the transmitted DF data number is 360. ; RA0 ( pin 2, output ): LED anodes, 010-060 degrees ( active = high ) ; RA1 ( pin 3, input ): baud rate select ( 1 of 2 ) ; RA2 ( pin 4, input ): baud rate select ( 2 of 2 ) ; RA3 ( pin 5 ): not used ; RA4 ( pin 6, input ): ORBIT / BLINK select ( low = orbit ) ; RB0 ( pin 21, output ): LED cathodes, +00 degrees ( active = low ) ; RB1 ( pin 22, output ): LED cathodes, +10 degrees ( active = low ) ; RB2 ( pin 23, output ): LED cathodes, +20 degrees ( active = low ) ; RB3 ( pin 24, output ): LED cathodes, +30 degrees ( active = low ) ; RB4 ( pin 25, output ): LED cathodes, +40 degrees ( active = low ) ; RB5 ( pin 26, output ): LED cathodes, +50 degrees ( active = low ) ; RB6 ( pin 27, output ): LED anodes, 130-180 degrees ( active = high ) ; RB7 ( pin 28, output ): LED anodes, 070-120 degrees ( active = high ) ; RC0 ( pin 11, input ): FORMAT select ( high = true degrees ) ; RC1 ( pin 12, output ): LED anodes, 300-000 degrees ( active = high ) ; RC2 ( pin 13, output ): LED anodes, 250-300 degrees ( active = high ) ; RC3 ( pin 14, output ): DATA_GATE to 16F84 ( active = high ) ; RC4 ( pin 15, output ): DATA_CLOCK to 16F84 ( positive edge trigger ) ; RC5 ( pin 16, output ): LED anodes, 190-240 degrees ( active = high ) ; RC6 ( pin 17, output ): not used ( configured as UART output ) ; RC7 ( pin 18, input ): UART input ;--------------------------------------------------------- ; ; ASSEMBLER DIRECTIVES ; ;--------------------------------------------------------- processor 16c773 ; __config h'3fb1' ;config bits : ;memory protect = off ;pwr-on rst = on ;wdt = off ;osc = xtal ;brown-out = off ;--------------------------------------------------------- ; ; EXECUTABLE CODE BEGINS HERE ; ;--------------------------------------------------------- ;--------------------------------------------------------- ; ; COLDSTART routine ; ;--------------------------------------------------------- COLDSTART nop ;entry point ; ; Jump around interrupt handler ; goto MAINSTART ;jump around handler ;--------------------------------------------------------- ; ; INTERRUPT handler routine ( UART interrupts ) ; ;--------------------------------------------------------- org h'0004' ; INTERRUPT nop ;entry point ; ; Save CPU status to restore later ; movwf W_TEMP ;save W reg contents swapf STATUS,0 ;swap W and status bcf STATUS,RP0 ;force bank = 0 movwf STAT_TEMP ;save STATUS reg contents ; ; Make room in message buffer for new character ; movf BUFF11,0 ;get char no. 11 movwf BUFF12 ;move to char no. 12 movf BUFF10,0 ;get char no. 10 movwf BUFF11 ;move to char no. 11 movf BUFF9,0 ;get char no. 9 movwf BUFF10 ;move to char no. 10 movf BUFF8,0 ;get char no. 8 movwf BUFF9 ;move to char no. 9 movf BUFF7,0 ;get char no. 7 movwf BUFF8 ;move to char no. 8 movf BUFF6,0 ;get char no. 6 movwf BUFF7 ;move to char no. 7 movf BUFF5,0 ;get char no. 5 movwf BUFF6 ;move to char no. 6 movf BUFF4,0 ;get char no. 4 movwf BUFF5 ;move to char no. 5 movf BUFF3,0 ;get char no. 3 movwf BUFF4 ;move to char no. 4 movf BUFF2,0 ;get char no. 2 movwf BUFF3 ;move to char no. 3 movf BUFF1,0 ;get char no. 1 movwf BUFF2 ;move to char no. 2 ; ; Get and store the new character from UART ; movf RCREG,0 ;get character andlw h'7f' ;top 7 bits only movwf BUFF1 ;save it ; ; Increment the character counter ; Check if this character is a "%" ( = start of message ) ; If so, reset the character counter to 0 ; incf CHAR_CNT,1 ;CHAR_CNT = CHAR_CNT + 1 movlw h'25' ;ASCII "%" subwf BUFF1,0 ; btfsc STATUS,ZRO ;last char = "%" ? clrf CHAR_CNT ;if so, CHAR_CNT = 0 ; ; Check if this character is a carriage return ; If not, exit ; movlw CR ;carriage return subwf BUFF1,0 ;check last char btfss STATUS,ZRO ;last char = CR ? goto INT_2 ;if not, jump ; ; CR detected ( = end of message ) ; Check CHAR_CNT to determine message format ; If CHAR_CNT = 6, message is Agrello format ; If CHAR_CNT = 10, message is extended Agrello format ; Otherwise, error in message ; ; ; Check if CHAR_CNT = 6 ( Agrello format ) ; movlw h'06' ; subwf CHAR_CNT,0 ; btfss STATUS,ZRO ;CHAR_CNT = 6 ? goto INT_1 ;if not, jump ; ; CHAR_CNT = 6 : Agrello format message ; Save BUFF4, BUFF5, and BUFF6 contents as DF bearing ; Clear HDG buffers ( compass data not available ) ; movf BUFF4,0 ;save ASCII BRG X1 movwf BRGX1 ; movf BUFF5,0 ;save ASCII BRG X10 movwf BRGX10 ; movf BUFF6,0 ;save ASCII BRG X100 movwf BRGX100 ; movlw h'30' ;= ASCII "0" movwf HDGX1 ;no compass data available movwf HDGX10 ; movwf HDGX100 ; ; ; Set NEW flag ( new message has arrived ) and exit ; bsf NEW,0 ; goto INT_2 ;exit ; ; Check if CHAR_CNT = 10 ( extended Agrello format ) ; INT_1 movlw h'0a' ; subwf CHAR_CNT,0 ; btfss STATUS,ZRO ;CHAR_CNT = 10 ? goto INT_2 ;if not, error, exit ; ; Character count = 10 = extended Agrello format message ; Save BUFF8, BUFF9, and BUFF10 contents as DF bearing ; movf BUFF8,0 ;save ASCII BRG X1 movwf BRGX1 ; movf BUFF9,0 ;save ASCII BRG X10 movwf BRGX10 ; movf BUFF10,0 ;save ASCII BRG X100 movwf BRGX100 ; ; ; Save BUFF2, BUFF3, and BUFF4 contents as compass heading ; movf BUFF2,0 ;save ASCII HDG X1 movwf HDGX1 ; movf BUFF3,0 ;save ASCII HDG X10 movwf HDGX10 ; movf BUFF4,0 ;save ASCII HDG X100 movwf HDGX100 ; ; ; Set NEW flag ( new message has arrived ) ; bsf NEW,0 ; ; ; Restore CPU status and return ; INT_2 swapf STAT_TEMP,W ;restore STATUS reg contents movwf STATUS ; swapf W_TEMP,1 ;restore W reg swapf W_TEMP,0 ; retfie ;done, return ;--------------------------------------------------------- ; ; MAINSTART routine ; ;--------------------------------------------------------- MAINSTART nop ;entry point ; ; De-select all analog inputs ( default = on ) ; bsf STATUS,RP0 ;select bank 1 bsf ADCON1,0 ; bsf ADCON1,1 ; bsf ADCON1,2 ; bsf ADCON1,3 ; bcf STATUS,RP0 ;back to bank 0 ; ; Configure the parallel ports ; bsf STATUS,RP0 ;select bank 1 bcf TRISA,RA0 ;pin 2 = output bcf TRISB,RB0 ;pin 21 = output bcf TRISB,RB1 ;pin 22 = output bcf TRISB,RB2 ;pin 23 = output bcf TRISB,RB3 ;pin 24 = output bcf TRISB,RB4 ;pin 25 = output bcf TRISB,RB5 ;pin 26 = output bcf TRISB,RB6 ;pin 27 = output bcf TRISB,RB7 ;pin 28 = output bcf TRISC,RC1 ;pin 12 = output bcf TRISC,RC2 ;pin 13 = output bcf TRISC,RC3 ;pin 14 = output bcf TRISC,RC4 ;pin 15 = output bcf TRISC,RC5 ;pin 16 = output bcf STATUS,RP0 ;back to bank 0 ; ; Identify the baud rate ( examine straps on pins 3 and 4 ) ; ; Test for 1200 baud ( pin 3 = lo, pin 4 = lo ) ; btfsc PORTA,RA1 ;pin 3 = lo ? goto MS_1 ;if not, jump btfsc PORTA,RA2 ;pin 4 = lo ? goto MS_1 ;if not, jump ; ; 1200 baud is selected ; Switch to bank 1 and proceed ; bsf STATUS,RP0 ;switch to bank 1 movlw BAUD1 ;SPBRG baud byte movwf SPBRG ;save it goto MS_4 ;exit ; ; Test for 2400 baud ( pin 3 = hi, pin 4 = lo ) ; MS_1 btfss PORTA,RA1 ;pin 3 = hi ? goto MS_2 ;if not, jump btfsc PORTA,RA2 ;pin 4 = lo ? goto MS_2 ;if not, jump ; ; 2400 baud is selected ; Switch to bank 1 and proceed ; bsf STATUS,RP0 ;switch to bank 1 movlw BAUD2 ;SPBRG baud byte movwf SPBRG ;save it goto MS_4 ;exit ; ; Test for 4800 baud ( pin 3 = lo, pin 4 = hi ) ; MS_2 btfsc PORTA,RA1 ;pin 3 = lo ? goto MS_3 ;if not, jump btfss PORTA,RA2 ;pin 4 = hi ? goto MS_3 ;if not, jump ; ; 4800 baud is selected ; Switch to bank 1 and proceed ; bsf STATUS,RP0 ;switch to bank 1 movlw BAUD3 ;SPBRG baud byte movwf SPBRG ;save it goto MS_4 ;exit ; ; If CPU gets here, 9600 baud is selected ( no test req'd ) ; Switch to bank 1 and proceed ; MS_3 bsf STATUS,RP0 ;switch to bank 1 movlw BAUD4 ;SPBRG baud byte movwf SPBRG ;save it ; ; Finish the UART configuration ( bank 1 still selected ) ; MS_4 movlw h'00' ;TXSTA config byte ;mode = async ;baud = low speed ;no TX movwf TXSTA ;save config byte bsf PIE1,RCIE ;enable UART interrupts ; ; Back to bank 0 ; bcf STATUS,RP0 ;back to bank 0 movlw h'90' ;RCSTA config byte ;UART = enabled ;8 bit recieve ;cw recieve = on ;address detect = off movwf RCSTA ;save it ; ; Initial values for variables ; clrf BL_STAT ;blink status clrf FL_CNT1 ;flash counters clrf FL_CNT2 ; incf FL_CNT1,1 ; incf FL_CNT2,1 ; clrf ORB_CTR ;orbit counter clrf VALID ; incf VALID,1 ;VALID = true clrf NEW ; incf NEW,1 ;NEW = true movlw VT1 ;load for VALTIM1 movwf VALTIM1 ; movlw VT2 ;load for VALTIM2 movwf VALTIM2 ; movlw TIM1VAL ;load for NUMTIM1 movwf NUMTIM1 ; movlw TIM2VAL ;load for NUMTIM2 movwf NUMTIM2 ; movlw h'30' ;load brg = 000 movwf BRGX1 ; movwf BRGX10 ; movwf BRGX100 ; clrf ORB_LED ;begin at 1st LED ; ; Clear the UART registers ; Enable interrupts and proceed ; movf RCREG,0 ;throw away data bcf PIR1,RCIF ;clear UART interrupt flag bsf INTCON,PEIE ;enable UART interrupts bsf INTCON,GIE ;enable all interrupts ;--------------------------------------------------------- ; ; EXECutive routine ; ;--------------------------------------------------------- EXEC nop ;entry point ; ; Lamp test ; call TEST ; ; ; Main loop is here ; EXEC_1 call MESSAGE ; call DISPLAY ; call FLASH ; call ORBIT ; call NUMERIC ; goto EXEC_1 ; ;--------------------------------------------------------- ; ; MESSAGE : Message testing / processing routine ; ;--------------------------------------------------------- MESSAGE nop ;entry point ; ; Increment the VALID timeout counter ; Proceed to MESSAGE_2 if no overflow ; incfsz VALTIM1,1 ;VALTIM1 = VALTIM1 + 1 goto MESSAGE_2 ;jump if no overflow incfsz VALTIM2,1 ;VALTIM2 = VALTIM2 + 1 goto MESSAGE_2 ;jump if no overflow ; ; Data is not valid ; Make VALID = false ; Make numeric bearing = 360 ( = invalid ) ; Send bearing to numeric display and return ; MESSAGE_1 clrf VALID ;VALID = false movlw h'01' ;=256 movwf NUMHI ; movlw h'68' ;=360-256 movwf NUMLO ; call NUMERIC_1 ;send to numeric chip return ;done, return ; ; Check if a new message is available ; MESSAGE_2 btfss NEW,0 ;new message arrived ? return ;if not, return ; ; New message has arrived ; Reset the NEW flag bit ; clrf NEW ; ; ; Check ASCII compass heading characters, confirm they are numeric ; movlw h'30' ;lower limit subwf HDGX1,0 ; btfss STATUS,CY ;char val < 30 ? goto MESSAGE_1 ;if so, data invalid, jump movlw h'30' ;lower limit subwf HDGX10,0 ; btfss STATUS,CY ;char val < 30 ? goto MESSAGE_1 ;if so, data invalid, jump movlw h'30' ;lower limit subwf HDGX100,0 ; btfss STATUS,CY ;char val < 30 ? goto MESSAGE_1 ;if so, data invalid, jump movlw h'3a' ;upper limit subwf HDGX1,0 ; btfsc STATUS,CY ;char val > 3a ? goto MESSAGE_1 ;if so, data invalid, jump movlw h'3a' ;upper limit subwf HDGX10,0 ; btfsc STATUS,CY ;char val > 3a ? goto MESSAGE_1 ;if so, data invalid, jump movlw h'3a' ;upper limit subwf HDGX100,0 ; btfsc STATUS,CY ;char val > 3a ? goto MESSAGE_1 ;if so, data invalid, jump ; ; ASCII compass heading characters are confirmed numeric ; Convert them to BCD numbers ; Generate a binary number for range checking ; movlw h'0f' ;mask for ASCII to BCD convert andwf HDGX1,1 ;convert from ASCII to BCD andwf HDGX10,1 ; andwf HDGX100,1 ; movf HDGX1,0 ;Prepare for binary convert movwf BCDX1 ; movf HDGX10,0 ; movwf BCDX10 ; movf HDGX100,0 ; movwf BCDX100 ; call BCDBIN ;generate binary number ; ; Check compass heading binary result for proper range ( 000 to 359 ) ; movlw h'02' ;check result hi byte subwf BINHI,0 ; btfsc STATUS,CY ;hi byte => 512 ? goto MESSAGE_1 ;if so, data invalid, jump btfss BINHI,0 ;hi byte = 256 ? goto MESSAGE_3 ;if not, jump movlw h'68' ;check result lo byte subwf BINLO,0 ; btfsc STATUS,CY ;lo byte => 104 ? goto MESSAGE_1 ;if so, data invalid, jump ; ; Check ASCII DF bearing characters, confirm they are numeric ; MESSAGE_3 movlw h'30' ;lower limit subwf BRGX1,0 ; btfss STATUS,CY ;char val < 30 ? goto MESSAGE_1 ;if so, data invalid, jump movlw h'30' ;lower limit subwf BRGX10,0 ; btfss STATUS,CY ;char val < 30 ? goto MESSAGE_1 ;if so, data invalid, jump movlw h'30' ;lower limit subwf BRGX100,0 ; btfss STATUS,CY ;char val < 30 ? goto MESSAGE_1 ;if so, data invalid, jump movlw h'3a' ;upper limit subwf BRGX1,0 ; btfsc STATUS,CY ;char val > 3a ? goto MESSAGE_1 ;if so, data invalid, jump movlw h'3a' ;upper limit subwf BRGX10,0 ; btfsc STATUS,CY ;char val > 3a ? goto MESSAGE_1 ;if so, data invalid, jump movlw h'3a' ;upper limit subwf BRGX100,0 ; btfsc STATUS,CY ;char val > 3a ? goto MESSAGE_1 ;if so, data invalid, jump ; ; ASCII DF bearing characters are confirmed numeric ; Convert them to BCD numbers ; Generate a binary number for range checking ; movlw h'0f' ;mask for ASCII to BCD convert andwf BRGX1,1 ; andwf BRGX10,1 ; andwf BRGX100,1 ; movf BRGX1,0 ;Prepare for binary convert movwf BCDX1 ; movf BRGX10,0 ; movwf BCDX10 ; movf BRGX100,0 ; movwf BCDX100 ; call BCDBIN ;generate binary number ; ; Check DF bearing binary result for proper range ( 000 to 359 ) ; movlw h'02' ;check result hi byte subwf BINHI,0 ; btfsc STATUS,CY ;hi byte => 512 ? goto MESSAGE_1 ;if so, data invalid, jump btfss BINHI,0 ;hi byte = 256 ? goto MESSAGE_4 ;if not, jump movlw h'68' ;check result lo byte subwf BINLO,0 ; btfsc STATUS,CY ;lo byte => 104 ? goto MESSAGE_1 ;if so, data invalid, jump ; ; If CPU arrives here, all data is valid ; MESSAGE_4 nop ; ; ; Check if "north-stabilized" display is selected ; If so, call NORTH routine to adjust the numbers ; btfss PORTC,RC0 ;check FORMAT strap goto MESSAGE_5 ;jump if display = relative call NORTH ;adjust numbers for north ; ; Save binary results for NUMERIC readout ; MESSAGE_5 movf BINHI,0 ;get hi byte movwf NUMHI ;save it movf BINLO,0 ;get lo byte movwf NUMLO ;save it ; ; Check if data was previously not valid ; If so, instantly update the numeric display ; btfss VALID,0 ;VALID = true ? call NUMERIC_1 ;if not, update numeric display ; ; Set VALID = true ; Reload the VALID timeout timers with starting values ; bsf VALID,0 ;VALID = true movlw VT1 ;reload for VALTIM1 movwf VALTIM1 ; movlw VT2 ;reload for VALTIM2 movwf VALTIM2 ; ; ; Reset blink status to "blink not in progress" ; clrf BL_STAT ; ; ; Perform BCD to binary conversion again, but divide-by-ten ; ( for pelorus display ) ; movf BRGX10,0 ;ASCII bearing X10 movwf BCDX1 ;save it in X1 movf BRGX100,0 ;ASCII bearing X100 movwf BCDX10 ;save it in X10 clrf BCDX100 ;BCDX100 = 0 call BCDBIN ;convert to binary movf BINLO,0 ;get result, 0 to 35 movwf BIN_LED ;save it ; ; Adjust binary value for "centered" display ; ( +5 to -4 degrees per LED, "rounded off" ) ; movlw h'06' ; subwf BRGX1,0 ;BRGX1 => 6 ? btfss STATUS,CY ; return ;if not, return ; ; BRGX1 is greater than 5 ; Add 1 to BIN_LED ; incf BIN_LED,1 ;BIN_LED = BIN_LED + 1 ; ; Check for overflow ( BIN_LED > 35 ) ; If overflow, reset BIN_LED ( BIN_LED = 0 ) ; movlw h'23' ; subwf BIN_LED,0 ; btfss STATUS,CY ;BIN_LED > 35 ? return ;if not, return clrf BIN_LED ; return ;done, return ;--------------------------------------------------------- ; ; NUMERIC : 2-wire serial driver for 16F84 numeric display ; ;--------------------------------------------------------- NUMERIC nop ;entry point ; ; Check if valid data is available ; btfss VALID,0 ;data = valid ? return ;if not, return ; ; Check if time = now to send data ; incfsz NUMTIM1,1 ;NUMTIM1 = NUMTIM1 + 1 return ;not yet, return incfsz NUMTIM2,1 ;NUMTIM2 = NUMTIM2 + 1 return ;not yet, return ; ; Time = now to send numeric data ; Reload the timers with starting values and proceed ; movlw TIM1VAL ;NUMTIM1 reload value movwf NUMTIM1 ;save it movlw TIM2VAL ;NUMTIM2 reload value movwf NUMTIM2 ;save it ; ; Alternate entry point if data goes invalid ; NUMERIC_1 nop ;entry point ; ; Set DATA_GATE = high ( enable transmission ) ; Wait a short time to ensure detection by U2 ; bsf PORTC,RC3 ;DATA_GATE = high movlw h'40' ;prepare for delay loop movwf NDX1 ;NDX1 = 64 clrf NDX2 ;NDX2 = 0 clrf NDX3 ;NDX3 = 0 call DELAY ;delay ; ; Check if DF bearing exceeds 255 ; If so, send 256 clock pulses ; btfss NUMHI,0 ;bearing > 255 ? goto NUMERIC_3 ;if not, jump clrf NDX1 ;prepare for loop NUMERIC_2 bsf PORTC,RC4 ;DATA_CLOCK = high nop ;give it time nop ; nop ; nop ; nop ; nop ; nop ; nop ; nop ; nop ; bcf PORTC,RC4 ;DATA_CLOCK = low nop ;give it time nop ; nop ; nop ; nop ; nop ; nop ; nop ; nop ; nop ; decfsz NDX1,1 ;done yet ? goto NUMERIC_2 ;if not, loop ; ; Send remaining clock pulses ; NUMERIC_3 movf NUMLO,0 ;get data lo byte movwf NDX1 ;save it incf NDX1,1 ;adjust for loop test NUMERIC_4 decfsz NDX1,1 ;done yet ? goto NUMERIC_5 ;if not, make a pulse goto NUMERIC_6 ;otherwise, exit loop NUMERIC_5 bsf PORTC,RC4 ;DATA_CLOCK = high nop ;give it time nop ; nop ; nop ; nop ; nop ; nop ; nop ; nop ; nop ; bcf PORTC,RC4 ;DATA_CLOCK = low nop ;give it time nop ; nop ; nop ; nop ; nop ; nop ; nop ; nop ; nop ; goto NUMERIC_4 ;loop ; ; Reset DATA_GATE and return ; NUMERIC_6 bcf PORTC,RC3 ;DATA_GATE = lo return ;done, return ;--------------------------------------------------------- ; ; BCDBIN : BCD to binary convert routine ; ;--------------------------------------------------------- BCDBIN nop ;entry point ; ; Clear the results register ; clrf BINLO ; clrf BINHI ; ; ; Convert BCDX100 digit ; movf BCDX100,0 ;get a copy movwf NDX1 ;save it movlw h'64' ;decimal 100 call BCDBIN_1 ;do it ; ; Convert BCDX10 digit ; movf BCDX10,0 ;get a copy movwf NDX1 ;save it movlw h'0a' ;decimal 10 call BCDBIN_1 ;do it ; ; Convert BCDX1 digit and return ; movf BCDX1,0 ;get a copy movwf NDX1 ;save it movlw h'01' ;decimal 1 call BCDBIN_1 ;do it return ;done, return ; ; Convert a single digit ; BCDBIN_1 incf NDX1,1 ;prepare for loop BCDBIN_2 decfsz NDX1,1 ;check if done goto BCDBIN_3 ;jump if not done return ;done, return BCDBIN_3 addwf BINLO,1 ;add binary btfsc STATUS,CY ;check for carry incf BINHI,1 ;if so, carry goto BCDBIN_2 ;continue loop ;--------------------------------------------------------- ; ; ORBIT : Orbit the display ( invalid data ) ; ;--------------------------------------------------------- ORBIT nop ;entry point ; ; Check if data is valid, return if true ; btfsc VALID,0 ;data valid ? return ;if so, return ; ; Check if BLINK is selected ; If so, jump to BLINK routine ; btfsc PORTA,RA4 ;BLINK selected ? goto BLINK ;if so, jump ; ; Check if new data has arrived, return if true ; ( this flag is set in the UART interrupt routine ) ; ORBIT_1 btfsc NEW,0 ;new data arrived ? return ;if so, return ; ; Point to next LED, check for overflow ; incf ORB_LED,1 ;ORB_LED = ORB_LED + 1 movlw h'25' ;check if result = 37 subwf ORB_LED,0 ; btfss STATUS,ZRO ;result = 37 ? goto ORBIT_2 ;if not, jump ; ; Overflow has occured, reset to first LED ; clrf ORB_LED ;clear ORB_LED incf ORB_LED,1 ;point to first LED ; ; Call routine to turn on the LED ; ORBIT_2 movf ORB_LED,0 ;get LED data movwf BIN_LED ;save it call DISPLAY ;do it ; ; Wait approx. 30 mSec ; clrf NDX1 ; movlw ORB_DLY ;get 30 mSec delay byte movwf NDX2 ;save it clrf NDX3 ; call DELAY ;wait 30 mSec goto ORBIT_1 ;loop ;--------------------------------------------------------- ; ; TEST : Lamp test routine ( time = power on ) ; ;--------------------------------------------------------- TEST nop ;entry point ; ; Point to next LED, check for overflow ; incf ORB_LED,1 ;ORB_LED = ORB_LED + 1 movlw h'25' ;check if result = 37 subwf ORB_LED,0 ; btfss STATUS,ZRO ;result = 37 ? goto TEST_2 ;if not, jump ; ; Overflow has occured, reset to first LED ; clrf ORB_LED ;clear ORB_LED incf ORB_LED,1 ;point to first LED ; ; Increment the orbit counter ; Check if ten orbits have been completed ; Return if true ( test = finished ) ; incf ORB_CTR,1 ;ORB_CTR = ORB_CTR +1 movlw h'08' ; subwf ORB_CTR,0 ; btfsc STATUS,ZRO ;eight orbits yet ? return ;if true, exit ; ; Call routine to turn on the LED ; TEST_2 movf ORB_LED,0 ;get LED data movwf BIN_LED ;save it call DISPLAY ;do it ; ; Wait approx. 30 mSec ; clrf NDX1 ; movlw ORB_DLY ;get 30 mSec delay byte movwf NDX2 ;save it clrf NDX3 ; call DELAY ;wait 30 mSec goto TEST ;loop ;--------------------------------------------------------- ; ; BLINK : Display blink routine ( invalid data ) ; ;--------------------------------------------------------- BLINK nop ;entry point ; ; Check if blink was already in progress ; btfsc BL_STAT,0 ;blink ( ON ) in progress ? goto BLINK_1 ;if so, jump btfsc BL_STAT,1 ;blink ( OFF ) in progress ? goto BLINK_2 ;if so, jump ; ; Blink was not in progress, start at beginning ; Load the delay registers with time for display = on ; movlw BLON_LO ; movwf BLNDX1 ; movlw BLON_MID ; movwf BLNDX2 ; movlw BLON_HI ; movwf BLNDX3 ; ; ; Increment delay values to prepare for loop ; incf BLNDX1,1 ; incf BLNDX2,1 ; incf BLNDX3,1 ; ; ; Change blink status to BLINK ON in progress ; bsf BL_STAT,0 ; ; ; Check if new data has arrived, return if true ; ( this flag is set in the UART interrupt routine ) ; BLINK_1 btfsc NEW,0 ;new data arrived ? return ;if so, return ; ; Delay approx 1 second ( display = on ) ; decfsz BLNDX1,1 ;NDX1 = NDX1 - 1 goto BLINK_1 ;loop if not zero decfsz BLNDX2,1 ;NDX2 = NDX2 - 1 goto BLINK_1 ;loop if not zero decfsz BLNDX3,1 ;NDX3 = NDX3 - 1 goto BLINK_1 ;loop if not zero ; ; Save the display data ; movf PORTA,0 ;get PORT A data movwf SAVE_A ;save display bits movf PORTB,0 ;get PORT B data movwf SAVE_B ;save display bits movf PORTC,0 ;get PORT C data movwf SAVE_C ;save display bits ; ; Turn off the display ; bcf PORTA,RA0 ;sector 1 = off bcf PORTB,RB7 ;sector 2 = off bcf PORTB,RB6 ;sector 3 = off bcf PORTC,RC5 ;sector 4 = off bcf PORTC,RC2 ;sector 5 = off bcf PORTC,RC1 ;sector 6 = off ; ; Load the delay registers with time for display = off ; movlw BLOFF_LO ; movwf BLNDX1 ; movlw BLOFF_MID ; movwf BLNDX2 ; movlw BLOFF_HI ; movwf BLNDX3 ; ; ; Increment delay values to prepare for loop ; incf BLNDX1,1 ; incf BLNDX2,1 ; incf BLNDX3,1 ; ; ; Change blink status to BLINK OFF in progress ; bcf BL_STAT,0 ; bsf BL_STAT,1 ; ; ; Check if new data has arrived, return if true ; ( this flag is set in the UART interrupt routine ) ; BLINK_2 btfsc NEW,0 ;new data arrived ? return ;if so, return ; ; Delay approx 0.2 second ( display = off) ; decfsz BLNDX1,1 ;NDX1 = NDX1 - 1 goto BLINK_2 ;loop if not zero decfsz BLNDX2,1 ;NDX2 = NDX2 - 1 goto BLINK_2 ;loop if not zero decfsz BLNDX3,1 ;NDX3 = NDX3 - 1 goto BLINK_2 ;loop if not zero ; ; Restore the display ; movf SAVE_A,0 ;retrieve PORT A data movwf PORTA ;restore PORT A data movf SAVE_B,0 ;retrieve PORT B data movwf PORTB ;restore PORT B data movf SAVE_C,0 ;retrieve PORT C data movwf PORTC ;restore PORT C data ; ; Change blink status from BLINK OFF to blink not in progress ; Loop to beginning ; clrf BL_STAT ; goto BLINK ;loop ;--------------------------------------------------------- ; ; FLASH : Flash the display ; ;--------------------------------------------------------- FLASH nop ;entry point ; ; Increment the flash counter ; Check if time to flash ; Return if not ; decfsz FL_CNT1,1 ;time to flash ? return ;if not, return decfsz FL_CNT2,1 ;time to flash ? return ;if not, return movlw FL_RATE1 ;reload flash counter movwf FL_CNT1 ; movlw FL_RATE2 ;reload flash counter movwf FL_CNT2 ; ; ; Save the display contents ; movf PORTA,0 ;get PORT A data movwf SAVE_A ;save it movf PORTB,0 ;get PORT B data movwf SAVE_B ;save it movf PORTC,0 ;get PORT C data movwf SAVE_C ;save it ; ; Extinguish all sectors and LEDs ; bcf PORTA,RA0 ;sector 1 = off bcf PORTB,RB7 ;sector 2 = off bcf PORTB,RB6 ;sector 3 = off bcf PORTC,RC5 ;sector 4 = off bcf PORTC,RC2 ;sector 5 = off bcf PORTC,RC1 ;sector 6 = off bsf PORTB,RB0 ;LED1 = off bsf PORTB,RB1 ;LED2 = off bsf PORTB,RB2 ;LED3 = off bsf PORTB,RB3 ;LED4 = off bsf PORTB,RB4 ;LED5 = off bsf PORTB,RB5 ;LED6 = off ; ; Flash each sector ; bsf PORTA,RA0 ;sector 1 = on call FLASH_1 ;flash it bcf PORTA,RA0 ;sector 1 = off bsf PORTB,RB7 ;sector 2 = on call FLASH_1 ;flash it bcf PORTB,RB7 ;sector 2 = off bsf PORTB,RB6 ;sector 3 = on call FLASH_1 ;flash it bcf PORTB,RB6 ;sector 3 = off bsf PORTC,RC5 ;sector 4 = on call FLASH_1 ;flash it bcf PORTC,RC5 ;sector 4 = off bsf PORTC,RC2 ;sector 5 = on call FLASH_1 ;flash it bcf PORTC,RC2 ;sector 5 = off bsf PORTC,RC1 ;sector 6 = on call FLASH_1 ;flash it goto FLASH_3 ; ; Flash each LED in one sector ; FLASH_1 bcf PORTB,RB0 ;LED1 = on call FLASH_2 ;do it bsf PORTB,RB0 ;LED1 = off bcf PORTB,RB1 ;LED2 = on call FLASH_2 ;do it bsf PORTB,RB1 ;LED2 = off bcf PORTB,RB2 ;LED3 = on call FLASH_2 ;do it bsf PORTB,RB2 ;LED3 = off bcf PORTB,RB3 ;LED4 = on call FLASH_2 ;do it bsf PORTB,RB3 ;LED4 = off bcf PORTB,RB4 ;LED5 = on call FLASH_2 ;do it bsf PORTB,RB4 ;LED5 = off bcf PORTB,RB5 ;LED6 = on call FLASH_2 ;do it bsf PORTB,RB5 ;LED6 = off return ;done, return ; ; Small time delay for each LED ; FLASH_2 movlw FL_BRITE ; movwf NDX1 ; FLASH_2A decfsz NDX1,1 ; goto FLASH_2A ; return ; ; ; Restore the display and return ; FLASH_3 movf SAVE_A,0 ;get PORT A data movwf PORTA ;restore it movf SAVE_B,0 ;get PORT B data movwf PORTB ;restore it movf SAVE_C,0 ;get PORT C data movwf PORTC ;restore it return ;done, return ;--------------------------------------------------------- ; ; DISPLAY : Turn on the display LED ; ;--------------------------------------------------------- DISPLAY nop ;entry point ; ; Get the A port bits to turn on the LED ; movf BIN_LED,0 ;get binary data call LEDA_HI ;get A port hi bits movwf A_HI ;save them movf BIN_LED,0 ;get binary data call LEDA_LO ;get A port lo bits movwf A_LO ;save them ; ; Get the B port bits to turn on the LED ; movf BIN_LED,0 ;get binary data call LEDB_HI_LO ;get B port bits movwf B_HI_LO ;save them ; ; Get the C port bits to turn on the LED ; movf BIN_LED,0 ;get binary data call LEDC_HI ;get C port hi bits movwf C_HI ;save them movf BIN_LED,0 ;get binary data call LEDC_LO ;get C port lo bits movwf C_LO ;save them ; ; Turn on the LED and return ; movf A_HI,0 ;get A port hi bits iorwf PORTA,1 ;do it movf A_LO,0 ;get A port lo bits andwf PORTA,1 ;do it movf B_HI_LO,0 ;get B port bits movwf PORTB ;do it movf C_HI,0 ;get C port hi bits iorwf PORTC,1 ;do it movf C_LO,0 ;get C port lo bits andwf PORTC,1 ;do it return ;done, return ;--------------------------------------------------------- ; ; DELAY : Time delay routine ; ;--------------------------------------------------------- DELAY nop ;entry point ; ; Prepare indexes for delay loop ; incf NDX1,1 ;NDX1 = NDX1 + 1 incf NDX2,1 ;NDX2 = NDX2 + 1 incf NDX3,1 ;NDX3 = NDX3 + 1 ; ; Loop until all indexes are zero ; DELAY_1 decfsz NDX1,1 ;NDX1 = NDX1 - 1 goto DELAY_1 ;loop if not zero decfsz NDX2,1 ;NDX2 = NDX2 - 1 goto DELAY_1 ;loop if not zero decfsz NDX3,1 ;NDX3 = NDX3 - 1 goto DELAY_1 ;loop if not zero return ;done, return ;--------------------------------------------------------- ; ; NORTH : Generate data for a north-stabilized display ; ;--------------------------------------------------------- NORTH nop ;entry point ; ; Add compass BCD heading to DF bearing ; movf HDGX1,0 ; movwf BCDX1 ; movf HDGX10,0 ; movwf BCDX10 ; movf HDGX100,0 ; movwf BCDX100 ; movf BRGX1,0 ; movwf BCDX1T ; movf BRGX10,0 ; movwf BCDX10T ; movf BRGX100,0 ; movwf BCDX100T ; call BCDSUM ; ; ; Check if result has overflowed ( > 359 degrees ) ; Check if BCDX100 => 3 ; movlw h'03' ;check if BCDX100 => 3 subwf BCDX100,0 ; btfss STATUS,CY ;BCDX100 => 3 ? goto NORTH_2 ;if not, jump ; ; BCDX100 is => 3 ; Check if BCDX100 = 3 ; btfss STATUS,ZRO ; goto NORTH_1 ;BCDX100 > 3, jump ; ; BCDX100 = 3 ; Check if BCDX10 => 6 ; movlw h'06' ;check if BCDX10 => 6 subwf BCDX10,0 ; btfss STATUS,CY ;BCDX10 => 6 ? goto NORTH_2 ;if not, jump ; ; Result has overflowed, subtract 360 degrees ; ( use ten's complement addition ) ; ( add 640 and discard the overflow ) ; NORTH_1 movlw h'00' ; movwf BCDX1T ; movlw h'04' ; movwf BCDX10T ; movlw h'06' ; movwf BCDX100T ; call BCDSUM ; ; ; Sum is completed and correct ; Store the north-stabilized BCD result ; Generate a new north-stabilized binary result ; NORTH_2 movf BCDX1,0 ; movwf BRGX1 ; movf BCDX10,0 ; movwf BRGX10 ; movf BCDX100,0 ; movwf BRGX100 ; call BCDBIN ; ; ; All done, return ; return ; ;--------------------------------------------------------- ; ; BCDSUM : Add two 3-digit BCD numbers ; ;--------------------------------------------------------- BCDSUM nop ;entry point ; ; Add two BCD X1 digits ; BCDSUM1 clrw ; addwf BCDX1,0 ;get first term BCD X1 digit addwf BCDX1T,0 ;add second term movwf BCDX1 ;store result addlw OFLOW ;check if result < 10 btfss STATUS,CY ; goto BCDSUM2 ;if result < 10, then jump incf BCDX10,1 ;carry 1 to BCDX10 digit movlw TEN ;subtract 10 from BCD X1 result subwf BCDX1,1 ;save corrected BCD X1 result ; ; Add two BCD X10 digits ; BCDSUM2 clrw ; addwf BCDX10,0 ;get first term BCD X10 digit addwf BCDX10T,0 ;add second term movwf BCDX10 ;store result addlw OFLOW ;check if result < 10 btfss STATUS,CY ; goto BCDSUM3 ;if result < 10, then jump incf BCDX100,1 ;carry 1 to BCDX100 digit movlw TEN ;subtract 10 from BCD X10 result subwf BCDX10,1 ;save corrected BCD X10 result ; ; Add two BCD X100 digits ; BCDSUM3 clrw ; addwf BCDX100,0 ;get first term BCD X10 digit addwf BCDX100T,0 ;add second term movwf BCDX100 ;store result addlw OFLOW ;check if result < 10 btfss STATUS,CY ; goto BCDSUM4 ;if result < 10, then jump movlw TEN ;subtract 10 from BCD X100 result subwf BCDX100,1 ;save corrected BCD X100 result ; ; Done, return ; BCDSUM4 return ;done org h'0300' ;origin for lookup tables ;--------------------------------------------------------- ; ; LEDA_HI : Get A port hi LED bits ; ;--------------------------------------------------------- LEDA_HI nop ;entry point movwf TAB_NDX ;save index movlw h'03' ;high byte of table address movwf PCLATH ;prepare for table call movf TAB_NDX,0 ;get index addwf PCL,1 ;jump to table entry retlw h'00' ;LED 00 hi bits retlw h'01' ;LED 01 retlw h'01' ;LED 02 retlw h'01' ;LED 03 retlw h'01' ;LED 04 retlw h'01' ;LED 05 retlw h'01' ;LED 06 retlw h'00' ;LED 07 retlw h'00' ;LED 08 retlw h'00' ;LED 09 retlw h'00' ;LED 10 retlw h'00' ;LED 11 retlw h'00' ;LED 12 retlw h'00' ;LED 13 retlw h'00' ;LED 14 retlw h'00' ;LED 15 retlw h'00' ;LED 16 retlw h'00' ;LED 17 retlw h'00' ;LED 18 retlw h'00' ;LED 19 retlw h'00' ;LED 20 retlw h'00' ;LED 21 retlw h'00' ;LED 22 retlw h'00' ;LED 23 retlw h'00' ;LED 24 retlw h'00' ;LED 25 retlw h'00' ;LED 26 retlw h'00' ;LED 27 retlw h'00' ;LED 28 retlw h'00' ;LED 29 retlw h'00' ;LED 30 retlw h'00' ;LED 31 retlw h'00' ;LED 32 retlw h'00' ;LED 33 retlw h'00' ;LED 34 retlw h'00' ;LED 35 retlw h'00' ;LED 00 hi bits ;--------------------------------------------------------- ; ; LEDA_LO : Get A port lo LED bits ; ;--------------------------------------------------------- LEDA_LO nop ;entry point movwf TAB_NDX ;save index movlw h'03' ;high byte of table address movwf PCLATH ;prepare for table call movf TAB_NDX,0 ;get index addwf PCL,1 ;jump to table entry retlw h'fe' ;LED 00 lo bits retlw h'ff' ;LED 01 retlw h'ff' ;LED 02 retlw h'ff' ;LED 03 retlw h'ff' ;LED 04 retlw h'ff' ;LED 05 retlw h'ff' ;LED 06 retlw h'fe' ;LED 07 retlw h'fe' ;LED 08 retlw h'fe' ;LED 09 retlw h'fe' ;LED 10 retlw h'fe' ;LED 11 retlw h'fe' ;LED 12 retlw h'fe' ;LED 13 retlw h'fe' ;LED 14 retlw h'fe' ;LED 15 retlw h'fe' ;LED 16 retlw h'fe' ;LED 17 retlw h'fe' ;LED 18 retlw h'fe' ;LED 19 retlw h'fe' ;LED 20 retlw h'fe' ;LED 21 retlw h'fe' ;LED 22 retlw h'fe' ;LED 23 retlw h'fe' ;LED 24 retlw h'fe' ;LED 25 retlw h'fe' ;LED 26 retlw h'fe' ;LED 27 retlw h'fe' ;LED 28 retlw h'fe' ;LED 29 retlw h'fe' ;LED 30 retlw h'fe' ;LED 31 retlw h'fe' ;LED 32 retlw h'fe' ;LED 33 retlw h'fe' ;LED 34 retlw h'fe' ;LED 35 retlw h'fe' ;LED 00 lo bits ;--------------------------------------------------------- ; ; LEDB_HI_LO : Get B port LED bits ( hi and low ) ; ;--------------------------------------------------------- LEDB_HI_LO nop ;entry point movwf TAB_NDX ;save index movlw h'03' ;high byte of table address movwf PCLATH ;prepare for table call movf TAB_NDX,0 ;get index addwf PCL,1 ;jump to table entry retlw h'1f' ;LED 00 hi + lo bits retlw h'3e' ;LED 01 retlw h'3d' ;LED 02 retlw h'3b' ;LED 03 retlw h'37' ;LED 04 retlw h'2f' ;LED 05 retlw h'1f' ;LED 06 retlw h'be' ;LED 07 retlw h'bd' ;LED 08 retlw h'bb' ;LED 09 retlw h'b7' ;LED 10 retlw h'af' ;LED 11 retlw h'9f' ;LED 12 retlw h'7e' ;LED 13 retlw h'7d' ;LED 14 retlw h'7b' ;LED 15 retlw h'77' ;LED 16 retlw h'6f' ;LED 17 retlw h'5f' ;LED 18 retlw h'3e' ;LED 19 retlw h'3d' ;LED 20 retlw h'3b' ;LED 21 retlw h'37' ;LED 22 retlw h'2f' ;LED 23 retlw h'1f' ;LED 24 retlw h'3e' ;LED 25 retlw h'3d' ;LED 26 retlw h'3b' ;LED 27 retlw h'37' ;LED 28 retlw h'2f' ;LED 29 retlw h'1f' ;LED 30 retlw h'3e' ;LED 31 retlw h'3d' ;LED 32 retlw h'3b' ;LED 33 retlw h'37' ;LED 34 retlw h'2f' ;LED 35 retlw h'1f' ;LED 00 hi + lo bits ;--------------------------------------------------------- ; ; LEDC_HI : Get C port hi LED bits ; ;--------------------------------------------------------- LEDC_HI nop ;entry point movwf TAB_NDX ;save index movlw h'03' ;high byte of table address movwf PCLATH ;prepare for table call movf TAB_NDX,0 ;get index addwf PCL,1 ;jump to table entry retlw h'02' ;LED 00 hi bits retlw h'00' ;LED 01 retlw h'00' ;LED 02 retlw h'00' ;LED 03 retlw h'00' ;LED 04 retlw h'00' ;LED 05 retlw h'00' ;LED 06 retlw h'00' ;LED 07 retlw h'00' ;LED 08 retlw h'00' ;LED 09 retlw h'00' ;LED 10 retlw h'00' ;LED 11 retlw h'00' ;LED 12 retlw h'00' ;LED 13 retlw h'00' ;LED 14 retlw h'00' ;LED 15 retlw h'00' ;LED 16 retlw h'00' ;LED 17 retlw h'00' ;LED 18 retlw h'20' ;LED 19 retlw h'20' ;LED 20 retlw h'20' ;LED 21 retlw h'20' ;LED 22 retlw h'20' ;LED 23 retlw h'20' ;LED 24 retlw h'04' ;LED 25 retlw h'04' ;LED 26 retlw h'04' ;LED 27 retlw h'04' ;LED 28 retlw h'04' ;LED 29 retlw h'04' ;LED 30 retlw h'02' ;LED 31 retlw h'02' ;LED 32 retlw h'02' ;LED 33 retlw h'02' ;LED 34 retlw h'02' ;LED 35 retlw h'02' ;LED 00 hi bits ;--------------------------------------------------------- ; ; LEDC_LO : Get C port lo LED bits ; ;--------------------------------------------------------- LEDC_LO nop ;entry point movwf TAB_NDX ;save index movlw h'03' ;high byte of table address movwf PCLATH ;prepare for table call movf TAB_NDX,0 ;get index addwf PCL,1 ;jump to table entry retlw h'db' ;LED 00 lo bits retlw h'd9' ;LED 01 retlw h'd9' ;LED 02 retlw h'd9' ;LED 03 retlw h'd9' ;LED 04 retlw h'd9' ;LED 05 retlw h'd9' ;LED 06 retlw h'd9' ;LED 07 retlw h'd9' ;LED 08 retlw h'd9' ;LED 09 retlw h'd9' ;LED 10 retlw h'd9' ;LED 11 retlw h'd9' ;LED 12 retlw h'd9' ;LED 13 retlw h'd9' ;LED 14 retlw h'd9' ;LED 15 retlw h'd9' ;LED 16 retlw h'd9' ;LED 17 retlw h'd9' ;LED 18 retlw h'f9' ;LED 19 retlw h'f9' ;LED 20 retlw h'f9' ;LED 21 retlw h'f9' ;LED 22 retlw h'f9' ;LED 23 retlw h'f9' ;LED 24 retlw h'dd' ;LED 25 retlw h'dd' ;LED 26 retlw h'dd' ;LED 27 retlw h'dd' ;LED 28 retlw h'dd' ;LED 29 retlw h'dd' ;LED 30 retlw h'db' ;LED 31 retlw h'db' ;LED 32 retlw h'db' ;LED 33 retlw h'db' ;LED 34 retlw h'db' ;LED 35 retlw h'db' ;LED 00 lo bits ;--------------------------------------------------------- ; ; END OF EXECUTABLE CODE ; ;--------------------------------------------------------- ; ; LABEL DEFINITION AREA ; ;--------------------------------------------------------- ; ; PREDEFINED PIC REGISTERS ; STATUS equ h'03' ;STATUS register OPTN equ h'81' ;OPTION register INTCON equ h'0b' ;INTCON register TMR0 equ h'01' ;TMR0 register ADCON1 equ h'9f' ;ADCON1 register PCL equ h'02' ;PC LOW register PCLATH equ h'0a' ;PC HIGH register TRISA equ h'85' ;TRISA register TRISB equ h'86' ;TRISB register TRISC equ h'87' ;TRISC register PORTA equ h'05' ;PORTA register PORTB equ h'06' ;PORTB register PORTC equ h'07' ;PORTC register TXSTA equ h'98' ;TXSTA register RCSTA equ h'18' ;RCSTA register RCREG equ h'1a' ;RCREG register SPBRG equ h'99' ;SPBRG register PIE1 equ h'8c' ;PIE1 register PIR1 equ h'0c' ;PIR1 register ; ; PROGRAM CONSTANTS ; RP0 equ h'05' ;bank select bit in STATUS reg ZRO equ h'02' ;zero bit in STATUS reg CY equ h'00' ;carry bit in STATUS reg GIE equ h'07' ;global interrupt enable in INTCON reg RA0 equ h'00' ;PORTA bit 0 RA1 equ h'01' ;PORTA bit 1 RA2 equ h'02' ;PORTA bit 2 RA3 equ h'03' ;PORTA bit 3 RA4 equ h'04' ;PORTA bit 4 RB0 equ h'00' ;PORTB bit 0 RB1 equ h'01' ;PORTB bit 1 RB2 equ h'02' ;PORTB bit 2 RB3 equ h'03' ;PORTB bit 3 RB4 equ h'04' ;PORTB bit 4 RB5 equ h'05' ;PORTB bit 5 RB6 equ h'06' ;PORTB bit 6 RB7 equ h'07' ;PORTB bit 7 RC0 equ h'00' ;PORTC bit 0 RC1 equ h'01' ;PORTC bit 1 RC2 equ h'02' ;PORTC bit 2 RC3 equ h'03' ;PORTC bit 3 RC4 equ h'04' ;PORTC bit 4 RC5 equ h'05' ;PORTC bit 5 RC6 equ h'06' ;PORTC bit 6 RC7 equ h'07' ;PORTC bit 7 ORB_DLY equ h'10' ;orbit delay time BLON_LO equ h'00' ;blink ON time low byte BLON_MID equ h'00' ;blink ON time mid byte BLON_HI equ h'01' ;blink ON time hi byte BLOFF_LO equ h'00' ;blink OFF time lo byte BLOFF_MID equ h'40' ;blink OFF time mid byte BLOFF_HI equ h'00' ;blink OFF time hi byte FL_RATE1 equ h'00' ;display flash rate low byte FL_RATE2 equ h'20' ;display flash rate hi byte FL_BRITE equ h'20' ;display flash intensity VT1 equ h'00' ;VALID timeout lo reload byte VT2 equ h'80' ;VALID timeout hi reload byte BAUD1 equ h'2e' ;BAUD rate ( 1200 baud ) BAUD2 equ h'16' ;BAUD rate ( 2400 baud ) BAUD3 equ h'0b' ;BAUD rate ( 4800 baud ) BAUD4 equ h'05' ;BAUD rate ( 9600 baud ) CR equ h'0d' ;carriage return char RCIE equ h'05' ;RCIE bit in PIE1 register RCIF equ h'05' ;RCIF bit in PIR1 register PEIE equ h'06' ;PEIE bit in INTCON register IRP equ h'07' ;IRP bit in STATUS register TIM1VAL equ h'00' ;numeric timer 1 reload value TIM2VAL equ h'f0' ;numeric timer 2 reload value OFLOW equ D'246' ;constant ( BCD overflow test ) TEN equ D'10' ;constant ; ; PROGRAM VARIABLES ; STAT_TEMP equ h'20' ;temp storage for STATUS reg W_TEMP equ h'21' ;temp storage for W reg BINLO equ h'22' ;DF data lo byte BINHI equ h'23' ;DF data hi byte VALID equ h'24' ;DF data valid flag DIGIT equ h'25' ;digit select byte BCDOUT equ h'26' ;numeral data byte NDX1 equ h'27' ;loop index lo byte NDX2 equ h'28' ;loop index mid byte NDX3 equ h'29' ;loop index hi byte ANODE equ h'2a' ;anode identity, 1 to 6 CATHODE equ h'2b' ;cathode identity, 1 to 6 DECHI equ h'2c' ;decode data buffer, hi byte DECLO equ h'2d' ;decode data buffer, lo byte BCDX1 equ h'2e' ;BCDX1 sum result reg BCDX10 equ h'2f' ;BCDX10 sum result reg BCDX100 equ h'30' ;BCDX100 sum result reg A_HI equ h'31' ;PORT A bits to be set high A_LO equ h'32' ;PORT A bits to be set low B_HI_LO equ h'33' ;PORT B bits ( hi and low ) C_HI equ h'34' ;PORT C bits to be set hi C_LO equ h'35' ;PORT C bit to be set low TAB_NDX equ h'36' ;pointer for lookup tables ORB_LED equ h'37' ;pointer for current ORBIT LED BIN_LED equ h'38' ;binary number for DF LED BUFF1 equ h'39' ;RS232 buff, last char received BUFF2 equ h'3a' ;RS232 buff BUFF3 equ h'3b' ;RS232 buff BUFF4 equ h'3c' ;RS232 buff BUFF5 equ h'3d' ;RS232 buff BUFF6 equ h'3e' ;RS232 buff BUFF7 equ h'3f' ;RS232 buff BUFF8 equ h'40' ;RS232 buff BUFF9 equ h'41' ;RS232 buff BUFF10 equ h'42' ;RS232 buff BUFF11 equ h'43' ;RS232 buff BUFF12 equ h'44' ;RS232 buff NEW equ h'45' ;flag for NEW RS232 message VALTIM1 equ h'46' ; VALTIM2 equ h'47' ; VALTIM3 equ h'48' ; BRGX1 equ h'49' ;BCD/ASCII DF bearing, X1 digit BRGX10 equ h'4a' ;BCD/ASCII DF bearing, X10 digit BRGX100 equ h'4b' ;BCD/ASCII DF bearing, X100 digit NUMHI equ h'4c' ;numeric display binary data, hi byte NUMLO equ h'4d' ;numeric display binary data, lo byte NUMTIM1 equ h'4e' ;numeric update timer, lo byte NUMTIM2 equ h'4f' ;numeric update timer, hi byte HDGX1 equ h'50' ;BCD/ASCII compass hdg, X1 digit HDGX10 equ h'51' ;BCD/ASCII compass hdg, X10 digit HDGX100 equ h'52' ;BCD/ASCII compass hdg, X100 digit ORB_CTR equ h'53' ;LED self-test orbit counter SAVE_A equ h'54' ;PORT A data save/restore buffer SAVE_B equ h'55' ;PORT B data save/restore buffer SAVE_C equ h'56' ;PORT C data save/restore buffer FL_CNT1 equ h'57' ;LED flash counter, lo byte FL_CNT2 equ h'58' ;LED flash counter, hi byte BCDX1T equ h'59' ;BCD sum temporary reg, x1 digit BCDX10T equ h'5a' ;BCD sum temporary reg, x10 digit BCDX100T equ h'5b' ;BCD sum temporary reg, x100 digit CHAR_CNT equ h'5c' ;RS232 message character counter BLNDX1 equ h'5d' ;blink loop index, lo byte BLNDX2 equ h'5e' ;blink loop index, mid byte BLNDX3 equ h'5f' ;blink loop index, hi byte BL_STAT equ h'60' ;blink status byte ;--------------------------------------------------------- ; ; END OF SOURCE CODE ; ;--------------------------------------------------------- end