;********************************************************************************************** ;* * ;* GB3HT control software, V1.1 - operational since 11/2002 * ;* * ;********************************************************************************************** List P=PIC16F84, R=DEC ; include p16f84.inc ;register memory mapping file ;********************************* USER defined registers ************************************* incs_10mS EQU H'0010' ; Counts 10mS increments incs_100mS EQU H'0011' ; Counts 100mS increments incs_1S EQU H'0012' ; Counts 1S increments incs_1m EQU H'0013' ; Arm counter arm_timer EQU H'0014' ; Counts 1m increments flags_1 EQU H'0015' ; b0 - Send IDENT ; b1 - Send RSSI ; b2 - Send ALARMS ; b3 - Send PIP's ; b4 - Currently unused... ; b5 - Currently unused... ; b6 - Currently unused... ; b7 - CW timing marker flags_2 EQU H'0016' ; b0 - TX enabled ; b1 - T/T enabled ; b2 - Currently unused... ; b3 - Currently unused... ; b4 - Sending IDEENT ; b5 - Sending RSSI ; b6 - Sending ALARMS ; b7 - Sending PIP's ident_byte EQU H'0017' ; Ident data word - byte counter ident_word EQU H'0018' ; Ident data word - data word ident_bit EQU H'0019' ; Ident data word - bit counter alarm_byte EQU H'001A' ; Alarm data word - byte counter alarm_word EQU H'001B' ; Alarm data word - data word alarm_bit EQU H'001C' ; Alarm data word - bit counter pip_byte EQU H'001D' ; PIP's data word - byte counter pip_word EQU H'001E' ; PIP's data word - data word pip_bit EQU H'001F' ; PIP's data word - bit counter ;********************************************************************************************** ;* reset vector * ;********************************************************************************************** reset org H'0000' ;reset vector address goto start ;start program execution start org h'0006' ;start of program goto initialise ;********************************************************************************************** ;* system initialisation * ;********************************************************************************************** initialise bcf STATUS,RP0 ;goto bank0 movlw H'0000' ;disable all interrupts movwf INTCON bsf STATUS,RP0 ;goto bank1 movlw H'0007' ;set up prescaler movwf OPTION_REG ;TMR0 256:1 bcf STATUS,RP0 ;goto bank0 clrf TMR0 ;clear TMR0 clrwdt ;clear watchdog timer clrf PORTA ;porta configuration bsf STATUS,RP0 ; b0 - Alarm logic input movlw H'00FF' ; b1 - Carrier squelch logic input movwf TRISA ; b2 - CTCSS logic input bcf STATUS,RP0 ; b3 - Toneburst logic input ; b4 - Unused input ; b5 - Not implemented in PIP16F84 ; b6 - Not implemented in PIP16F84 ; b7 - Not implemented in PIP16F84 clrf PORTB ;portb configuration bsf STATUS,RP0 ; b0 - Key Tx movlw H'0000' ; b1 - Key CTCSS movwf TRISB ; b2 - Key T/T bcf STATUS,RP0 ; b3 - Key Piptone ; b4 - Piptone frequency ; b5 - Piptone level ; b6 - Ident cycle ; b7 - Heartbeat MOVLW 10 ; B'00001010' H'0A' MOVWF incs_10mS MOVWF incs_100mS MOVLW 60 ; B'00111100' H'3C' MOVWF incs_1S MOVLW 15 ; B'00001110' H'0E' MOVWF incs_1m CLRF arm_timer CLRF flags_1 CLRF flags_2 CALL ident_init CALL alarm_init CALL pip_init MOVLW 2 ; B'00000010' H'02' MOVWF arm_timer ;********************************************************************************************** ;* Main program loop * ;********************************************************************************************** main_loop CLRWDT ; Clear watchdog timer MOVLW 218 ; Timing generator... ADDWF TMR0,W ; --""-- BTFSC STATUS,C ; --""-- CALL soft_timing ; --""-- MOVF arm_timer,F BTFSC STATUS,Z GOTO ml_1 BTFSS flags_2,0 CALL en_tx ; Enable TX routine CALL sequencer ; CW sequencer routine ml_1 CALL status ; Receiver status checks routine MOVF arm_timer,F BTFSS STATUS,Z GOTO main_loop BTFSC flags_2,0 CALL dis_tx ; Disable TX routine GOTO main_loop ;********************************************************************************************** ;* Repeater hardware status checking * ;********************************************************************************************** status MOVF arm_timer,F BTFSS STATUS,Z GOTO st_2 BTFSS PORTA,2 ; Decoded CTCSS input GOTO st_1 MOVLW 2 ; Arm system MOVWF arm_timer ; --- "" --- GOTO st_2 st_1 BTFSS PORTA,3 ; Decoded Toneburst input RETURN MOVLW 2 ; Arm system MOVWF arm_timer ; --- "" --- st_2 BTFSS PORTA,1 ; C/S input GOTO st_3 MOVLW 2 ; Arm system MOVWF arm_timer ; --- "" --- BTFSC PORTA,3 ; Decoded Toneburst input GOTO st_3 BTFSS flags_2,1 CALL en_tt BTFSS flags_1,0 BCF PORTB,3 ; Disable PIP/IDENT tone generator BTFSC flags_2,7 CALL pip_init BTFSS PORTA,0 ; Generic ALARMS input RETURN BTFSC flags_2,6 CALL alarm_init RETURN st_3 BTFSC flags_2,1 ; Disable T/T if toneburst decode is active CALL dis_tt ; --""-- RETURN ; --""-- ;********************************************************************************************** ;* Enable TX * ;********************************************************************************************** en_tx BSF PORTB,0 BSF flags_2,0 RETURN ;********************************************************************************************** ;* Disable TX * ;********************************************************************************************** dis_tx BCF PORTB,0 BCF flags_2,0 RETURN ;********************************************************************************************** ;* Enable T/T * ;********************************************************************************************** en_tt BSF PORTB,2 BSF PORTB,1 BSF PORTB,4 BSF PORTB,5 BSF flags_2,1 RETURN ;********************************************************************************************** ;* Disable T/T * ;********************************************************************************************** dis_tt BCF PORTB,2 BCF PORTB,1 BCF PORTB,4 BCF PORTB,5 BCF flags_2,1 RETURN ;********************************************************************************************** ;* CW routine sequencer * ;********************************************************************************************** sequencer BTFSS flags_1,7 ; Check CW timing marker RETURN BTFSS flags_1,0 GOTO sq_1 CALL ident_send ; CW IDENT routine RETURN sq_1 BTFSC PORTA,1 RETURN BTFSS flags_1,2 GOTO sq_2 CALL alarm_send ; CW ALARM Indication routine RETURN sq_2 BTFSC flags_1,3 CALL pip_send ; CW PIPS routine RETURN ;********************************************************************************************** ;* Initialise IDENT (GB3HT_C) sequence * ;********************************************************************************************** ident_init CLRF ident_byte CLRF ident_word MOVF ident_byte,W CALL ident_dat MOVWF ident_word MOVLW 8 ; B'00001000' H'08' MOVWF ident_bit BSF flags_1,0 BCF flags_2,4 BSF PORTB,6 RETURN ;********************************************************************************************** ;* IDENT (GB3HT_C) data array * ;********************************************************************************************** ident_dat ADDWF PCL,F ; Ident data "GB3HT_C" RETLW 0 ; B'00000000' H'00' RETLW 0 ; B'00000000' H'00' RETLW 14 ; B'00001110' H'0E' RETLW 232 ; B'11101000' H'E8' RETLW 234 ; B'11101010' H'EA' RETLW 138 ; B'10001010' H'8A' RETLW 187 ; B'10111011' H'BB' RETLW 138 ; B'10001010' H'8A' RETLW 163 ; B'10100011' H'A3' RETLW 128 ; B'10000000' H'80' RETLW 58 ; B'00111010' H'3A' RETLW 232 ; B'11101000' H'E8' RETLW 0 ; B'00000000' H'00' RETLW 0 ; B'00000000' H'00' ;********************************************************************************************** ;* Send CW - IDENT (GB3HT_C) routine * ;********************************************************************************************** ident_send MOVLW 2 ; B'00000010' H'02' MOVWF arm_timer BSF flags_2,4 CALL id_1 MOVF ident_byte,W XORLW 13 ; B'00001101' H'0D' BTFSS STATUS,Z RETURN BCF flags_1,0 BCF PORTB,6 RETURN id_1 RLF ident_word,F BTFSS STATUS,C GOTO id_2 BSF PORTB,3 GOTO id_3 id_2 BCF PORTB,3 id_3 BCF flags_1,7 ; Clear CW timing marker DECFSZ ident_bit,F RETURN INCF ident_byte,F MOVF ident_byte,W CALL ident_dat MOVWF ident_word MOVLW 8 ; B'00001000' H'08' MOVWF ident_bit RETURN ;********************************************************************************************** ;* Initialise Alarm indication sequence * ;********************************************************************************************** alarm_init CLRF alarm_byte CLRF alarm_word MOVF alarm_byte,W CALL alarm_dat MOVWF alarm_word MOVLW 8 ; B'00001000' H'08' MOVWF alarm_bit BSF flags_1,2 BCF flags_2,6 RETURN ;********************************************************************************************** ;* Alarm indication data aarray * ;********************************************************************************************** alarm_dat ADDWF PCL,F ; Alarm signal data RETLW 0 ; B'00000000' H'00' RETLW 0 ; B'00000000' H'00' RETLW 23 ; B'00010111' H'17' RETLW 23 ; B'00010111' H'17' RETLW 81 ; B'01010001' H'51' RETLW 220 ; B'11011100' H'DC' RETLW 0 ; B'00000000' H'00' RETLW 0 ; B'00000000' H'00' ;********************************************************************************************** ;* Send CW - Alarm indication routine * ;********************************************************************************************** alarm_send MOVLW 2 ; B'00000010' H'02' MOVWF arm_timer BSF flags_2,6 CALL al_1 MOVF alarm_byte,W XORLW 7 ; B'00000111' H'07' BTFSS STATUS,Z RETURN BCF flags_1,2 RETURN al_1 RLF alarm_word,F BTFSS STATUS,C GOTO al_2 BSF PORTB,3 GOTO al_3 al_2 BCF PORTB,3 al_3 BCF flags_1,7 ; Clear CW timing marker DECFSZ alarm_bit,F RETURN INCF alarm_byte,F MOVF alarm_byte,W CALL alarm_dat MOVWF alarm_word MOVLW 8 ; B'00001000' H'08' MOVWF alarm_bit RETURN ;********************************************************************************************** ;* Initialise PIPs sequence * ;********************************************************************************************** pip_init CLRF pip_byte CLRF pip_word MOVF pip_byte,W CALL pip_dat MOVWF pip_word MOVLW 8 ; B'00001000' H'08' MOVWF pip_bit BSF flags_1,3 BCF flags_2,7 RETURN ;********************************************************************************************** ;* PIPs data array * ;********************************************************************************************** pip_dat ADDWF PCL,F ; PIPs data RETLW 0 ; B'00000000' H'00' RETLW 0 ; B'00000000' H'00' RETLW 128 ; B'10000000' H'80' RETLW 0 ; B'00000000' H'00' RETLW 128 ; B'10000000' H'80' RETLW 0 ; B'00000000' H'00' RETLW 128 ; B'10000000' H'80' RETLW 0 ; B'00000000' H'00' RETLW 128 ; B'10000000' H'80' RETLW 0 ; B'00000000' H'00' RETLW 128 ; B'10000000' H'80' RETLW 0 ; B'00000000' H'00' RETLW 128 ; B'10000000' H'80' RETLW 0 ; B'00000000' H'00' RETLW 128 ; B'10000000' H'80' RETLW 0 ; B'00000000' H'00' RETLW 128 ; B'10000000' H'80' RETLW 0 ; B'00000000' H'00' RETLW 0 ; B'00000000' H'00' ;********************************************************************************************** ;* Send CW - PIPs routine * ;********************************************************************************************** pip_send MOVLW 2 ; B'00000010' H'02' MOVWF arm_timer BSF flags_2,7 CALL pip_1 MOVF pip_byte,W XORLW 18 ; B'00010010' H'12' BTFSS STATUS,Z RETURN BCF flags_1,3 RETURN pip_1 RLF pip_word,F BTFSS STATUS,C GOTO pip_2 BSF PORTB,3 GOTO pip_3 pip_2 BCF PORTB,3 pip_3 BCF flags_1,7 ; Clear CW timing marker DECFSZ pip_bit,F RETURN INCF pip_byte,F MOVF pip_byte,W CALL pip_dat MOVWF pip_word MOVLW 8 ; B'00001000' H'08' MOVWF pip_bit RETURN ;********************************************************************************************** ;* soft timing routines * ;********************************************************************************************** soft_timing CLRWDT CLRF TMR0 ; 10mS counter DECF incs_10mS,F ; Decrements every 10mS BTFSS STATUS,Z RETURN MOVLW 10 ; 100mS counter MOVWF incs_10mS BSF flags_1,7 ; Set CW timing marker DECF incs_100mS,F ; Decrements every 100mS BTFSS STATUS,Z RETURN MOVLW 10 ; 1S counter & heartbeat driver MOVWF incs_100mS MOVF arm_timer,F BTFSS STATUS,Z DECF arm_timer,F BTFSS PORTB,7 ; Heartbeat indicator... GOTO so_1 BCF PORTB,7 GOTO so_2 so_1 BSF PORTB,7 so_2 DECF incs_1S,F ; Decrements every S BTFSS STATUS,Z RETURN MOVLW 60 ; Minute counter MOVWF incs_1S DECF incs_1m,F ; Decrements every minute BTFSS STATUS,Z RETURN MOVLW 15 ; Quarter hour counter MOVWF incs_1m MOVLW 2 ; Arm system - IDENT due... MOVWF arm_timer ; -"- CALL ident_init ; -"- RETURN END