'Define Inputs and Outputs and Registers ' 'Inputs 'Logic Use Physical 'In 0 Keypad Row 4 3 'In 1 Keypad Row 3 4 'In 2 Keypad Row 2 5 'In 3 Keypad Row 1 6 'In 4 Keypad Column 4 7 'In 5 Keypad Column 3 8 'In 6 Keypad Column 2 9 'In 7 Keypad Column 1 10 ' ' 'Outputs 'Logic Use Physical 'Out 0 In 7 & DTMF D0 18 'Out 1 In 6 & DTMF D1 17 'Out 2 In 5 & DTMF D2 16 'Out 3 In 4 & DTMF D3 15 'Out 4 DTMF Enable 14 'Out 5 Serial TX 13 'Out 6 PTT 12 'Out 7 **Unused 11 ' ' 'Registers 'Register Use 'B10 Key_Value 'B11 Row Scan 'B12 TX Timer 'B13 Mode (1 for DTMF and 2 for CAT) SYMBOL key_value = B10 SYMBOL row_scan = B11 SYMBOL Tx_timer = B12 SYMBOL Mode = B13 SETFREQ M8 EEPROM 0,("123A456B789*0#D") 'Load 16 keypad real numbers/chracters into memory Mode = 1 pause 2000 start: high 4 If Mode = 1 then goto DTMF_Mode If Mode = 2 then goto CAT_Mode DTMF_Mode: if Tx_timer = 0 then low 6 else dec Tx_timer endif 'debug Tx_timer gosub check_keys if key_value = 0 then goto start 'debug ROW_SCAN 'debug key_value pins = key_value Tx_timer = 50 high 6 low 4 pause 1000 key_value = 0 goto start CAT_Mode: goto start check_keys: row_scan = 1 'if row 1 key value will be between 1 and 4 high 2 'set to high to provide voltage to keypad row1 gosub check_column low 2 row_scan = 4 'if row 2 key value will be between 5 and 8 high 3 'set to high to provide voltage to keypad row2 gosub check_column low 3 row_scan = 7 'if row 3 key value will be between 9 and 12 high 1 'set to high to provide voltage to keypad row3 gosub check_column low 1 row_scan = 11 'if row 4 key value will be between 12 and 16 high 0 'set to high to provide voltage to keypad row4 gosub check_column low 0 'test the input pins for which column the key is in return check_column: if pin0 = 1 then gosub first'column if pin1 = 1 then gosub second'column if pin2 = 1 then gosub third'column if pin3 = 1 then gosub forth'column return first:'column key_value = row_scan 'No addition required, column number [1] return second:'column key_value = row_scan + 1 'This is row number + column number [2] return third:'column key_value = row_scan + 2 'This is row number + column number [3] return forth:'column if row_scan = 1 then key_value = 13 else endif if row_scan = 4 then key_value = 14 else endif if row_scan = 7 then key_value = 15 else endif if row_scan = 11 then key_value = 0 else endif 'key_value = row_scan + 4 'This is row number + column number [4] return