; ; ELEKEY2 ; Copyright (c) 2017.4.5 by (JM7OLW)Kousuke Matsumoto LIST P=PIC16F84A INCLUDE "P16F84A.INC" __CONFIG _RC_OSC & _WDT_OFF ;file register----------------------------------- tm1 EQU 21 tm2 EQU 22 dotd EQU 23 dashd EQU 24 ;------------------------------------------------ ORG 0 GOTO start ;------------------------------------------------ start BCF PORTA,2 ;KEY OFF BCF PORTA,3 ;BUZZER OFF BSF STATUS,RP0 ;bank1 MOVLW B'00011' ;set RA0,1 INPUT MOVWF TRISA ;85h=TRISA MOVLW B'11111111' ;set RB0-7 INPUT MOVWF TRISB ;86h=TRISB BCF STATUS,RP0 ;bank0 BTFSC PORTA,1 ;if RA1=0(dash=on) then straight000 GOTO start100 GOTO straight000 start100 BTFSC PORTB,0 ;if RB0=0(memory0=on) then straight000 GOTO main000 GOTO straight000 ;------------------------------------------------ ; straight key mode ;------------------------------------------------ straight000 ; memory check BTFSC PORTB,0 ;if RB0=0 then call memory0 GOTO straight410 CALL memory0 GOTO straight000 straight410 BTFSC PORTB,1 ;if RB1=0 then call memory1 GOTO straight420 CALL memory1 GOTO straight000 straight420 BTFSC PORTB,2 ;if RB2=0 then call memory2 GOTO straight430 CALL memory2 GOTO straight000 straight430 BTFSC PORTB,3 ;if RB3=0 then call memory3 GOTO straight440 CALL memory3 GOTO straight000 straight440 BTFSC PORTB,4 ;if RB4=0 then call memory4 GOTO straight450 CALL memory4 GOTO straight000 straight450 BTFSC PORTB,5 ;if RB5=0 then call memory5 GOTO straight460 CALL memory5 GOTO straight000 straight460 BTFSC PORTB,6 ;if RB6=0 then call memory6 GOTO straight470 CALL memory6 GOTO straight000 straight470 BTFSC PORTB,7 ;if RB7=0 then call memory7 GOTO straight500 CALL memory7 GOTO straight000 straight500 ; key check BTFSC PORTA,0 ;if RA0=0(dot=on) then straight200 GOTO straight600 GOTO straight700 straight600 ;key out = off BCF PORTA,2 ;KEY OFF BCF PORTA,3 ;BUZZER OFF GOTO straight000 straight700 ;key out = on BSF PORTA,2 ;KEY ON BSF PORTA,3 ;BUZZER ON GOTO straight000 ;------------------------------------------------ ; elekey mode ;------------------------------------------------ main000 CLRF dotd CLRF dashd BTFSC PORTA,0 ;if RA0=0(dot=on) then main100 GOTO main200 main100 ;execute DOT CALL dot BTFSS dashd,0 GOTO main000 CLRF dotd CLRF dashd GOTO main300 main200 BTFSC PORTA,1 ;if RA1=0(dash=on) then main300 GOTO main400 main300 ;execute DASH CALL dash BTFSS dotd,0 GOTO main000 CLRF dotd CLRF dashd GOTO main100 main400 BTFSC PORTB,0 ;if RB0=0 then call memory0 GOTO main410 CALL memory0 GOTO main000 main410 BTFSC PORTB,1 ;if RB1=0 then call memory1 GOTO main420 CALL memory1 GOTO main000 main420 BTFSC PORTB,2 ;if RB2=0 then call memory2 GOTO main430 CALL memory2 GOTO main000 main430 BTFSC PORTB,3 ;if RB3=0 then call memory3 GOTO main440 CALL memory3 GOTO main000 main440 BTFSC PORTB,4 ;if RB4=0 then call memory4 GOTO main450 CALL memory4 GOTO main000 main450 BTFSC PORTB,5 ;if RB5=0 then call memory5 GOTO main460 CALL memory5 GOTO main000 main460 BTFSC PORTB,6 ;if RB6=0 then call memory6 GOTO main470 CALL memory6 GOTO main000 main470 BTFSC PORTB,7 ;if RB7=0 then call memory7 GOTO main000 CALL memory7 GOTO main000 ;------------------------------------------------ ; sub routines ;------------------------------------------------ memory0 CALL sub_J CALL sub_M CALL sub_7 CALL sub_O CALL sub_L CALL sub_W RETURN ;------------------------------------------------ memory1 CALL sub_J CALL sub_M CALL sub_7 CALL sub_O CALL sub_L CALL sub_W CALL sub_slash CALL sub_7 RETURN ;------------------------------------------------ memory2 CALL sub_5 CALL sub_N CALL sub_N RETURN ;------------------------------------------------ memory3 CALL sub_5 CALL sub_N CALL sub_N CALL sub_O CALL sub_7 CALL sub_P RETURN ;------------------------------------------------ memory4 CALL sub_R RETURN ;------------------------------------------------ memory5 CALL sub_T CALL sub_U RETURN ;------------------------------------------------ memory6 CALL sub_Q CALL sub_S CALL sub_L RETURN ;------------------------------------------------ memory7 CALL sub_F CALL sub_B RETURN ;------------------------------------------------ sub_A CALL dot CALL dash CALL yasumi RETURN ;------------------------------------------------ sub_B CALL dash CALL dot CALL dot CALL dot CALL yasumi RETURN ;------------------------------------------------ sub_C CALL dash CALL dot CALL dash CALL dot CALL yasumi RETURN ;------------------------------------------------ sub_D CALL dash CALL dot CALL dot CALL yasumi RETURN ;------------------------------------------------ sub_E CALL dot CALL yasumi RETURN ;------------------------------------------------ sub_F CALL dot CALL dot CALL dash CALL dot CALL yasumi RETURN ;------------------------------------------------ sub_G CALL dash CALL dash CALL dot CALL yasumi RETURN ;------------------------------------------------ sub_H CALL dot CALL dot CALL dot CALL dot CALL yasumi RETURN ;------------------------------------------------ sub_I CALL dot CALL dot CALL yasumi RETURN ;------------------------------------------------ sub_J CALL dot CALL dash CALL dash CALL dash CALL yasumi RETURN ;------------------------------------------------ sub_K CALL dash CALL dot CALL dash CALL yasumi RETURN ;------------------------------------------------ sub_L CALL dot CALL dash CALL dot CALL dot CALL yasumi RETURN ;------------------------------------------------ sub_M CALL dash CALL dash CALL yasumi RETURN ;------------------------------------------------ sub_N CALL dash CALL dot CALL yasumi RETURN ;------------------------------------------------ sub_O CALL dash CALL dash CALL dash CALL yasumi RETURN ;------------------------------------------------ sub_P CALL dot CALL dash CALL dash CALL dot CALL yasumi RETURN ;------------------------------------------------ sub_Q CALL dash CALL dash CALL dot CALL dash CALL yasumi RETURN ;------------------------------------------------ sub_R CALL dot CALL dash CALL dot CALL yasumi RETURN ;------------------------------------------------ sub_S CALL dot CALL dot CALL dot CALL yasumi RETURN ;------------------------------------------------ sub_T CALL dash CALL yasumi RETURN ;------------------------------------------------ sub_U CALL dot CALL dot CALL dash CALL yasumi RETURN ;------------------------------------------------ sub_V CALL dot CALL dot CALL dot CALL dash CALL yasumi RETURN ;------------------------------------------------ sub_W CALL dot CALL dash CALL dash CALL yasumi RETURN ;------------------------------------------------ sub_X CALL dash CALL dot CALL dot CALL dash CALL yasumi RETURN ;------------------------------------------------ sub_Y CALL dash CALL dot CALL dash CALL dash CALL yasumi RETURN ;------------------------------------------------ sub_Z CALL dash CALL dash CALL dot CALL dot CALL yasumi RETURN ;------------------------------------------------ sub_slash CALL dash CALL dot CALL dot CALL dash CALL dot CALL yasumi RETURN ;------------------------------------------------ sub_1 CALL dot CALL dash CALL dash CALL dash CALL yasumi RETURN ;------------------------------------------------ sub_2 CALL dot CALL dot CALL dash CALL dash CALL dash CALL yasumi RETURN ;------------------------------------------------ sub_3 CALL dot CALL dot CALL dot CALL dash CALL dash CALL yasumi RETURN ;------------------------------------------------ sub_4 CALL dot CALL dot CALL dot CALL dot CALL dash CALL yasumi RETURN ;------------------------------------------------ sub_5 CALL dot CALL dot CALL dot CALL dot CALL dot CALL yasumi RETURN ;------------------------------------------------ sub_6 CALL dash CALL dot CALL dot CALL dot CALL dot CALL yasumi RETURN ;------------------------------------------------ sub_7 CALL dash CALL dash CALL dot CALL dot CALL dot CALL yasumi RETURN ;------------------------------------------------ sub_8 CALL dash CALL dash CALL dash CALL dot CALL dot CALL yasumi RETURN ;------------------------------------------------ sub_9 CALL dash CALL dash CALL dash CALL dash CALL dot CALL yasumi RETURN ;------------------------------------------------ sub_0 CALL dash CALL dash CALL dash CALL dash CALL dash CALL yasumi RETURN ;------------------------------------------------ dot BSF PORTA,2 ;KEY ON BSF PORTA,3 ;BUZZER ON MOVLW 3 CALL wait00 BCF PORTA,2 ;KEY OFF BCF PORTA,3 ;BUZZER OFF MOVLW 3 CALL wait00 RETURN ;------------------------------------------------ dash BSF PORTA,2 ;KEY ON BSF PORTA,3 ;BUZZER ON MOVLW 9 CALL wait00 BCF PORTA,2 ;KEY OFF BCF PORTA,3 ;BUZZER OFF MOVLW 3 CALL wait00 RETURN ;------------------------------------------------ yasumi MOVLW 6 CALL wait00 RETURN ;------------------------------------------------ wait00 MOVWF tm1 wait01 BTFSC PORTA,0 ;if RA0=0(dot=on) GOTO wait012 MOVLW 1 MOVWF dotd wait012 BTFSC PORTA,1 ;if RA1=0(dash=on) GOTO wait015 MOVLW 1 MOVWF dashd wait015 MOVLW 99 MOVWF tm2 wait02 DECFSZ tm2,1 GOTO wait02 DECFSZ tm1,1 GOTO wait01 RETURN END ;end program-------------------------------------