'*************************************************** '* Tiny26L ELEKEY CW TRX Program with Message '* 2004-1-2 by JN3XBY ex.JA6IRK '*************************************************** '+++++++++++++++ INITIAL SET +++++++++++++++ Config Porta = Output Config Portb = Output Ddra = &B00000110 Ddrb = &B11111010 Porta = &B11111001 'A1:LED Portb = &B01010101 'B1:Shift B4:-MUTE B6:Key Dim Tcnt As Byte Dim Keyina As Byte Dim Keyinb As Byte Dim Keyleng As Word Dim Dotleng As Word Dim Dashleng As Word Dim Spaceleng As Byte Dim Initmem As Byte Dim Speed As Word Dim Keymode As Byte Dim Keymem As Byte Dim Toneloop As Word 'Tone no jikan Dim Toneleng As Word 'syousuu keisan ha dekinai Dim Memadress As Byte Dim Mem As Byte Dim Memdatacnt As Byte Dim Wspace As Word Dim Keydata As Byte Dim Revkey As Byte Dim Revkeymem As Byte Dim Loopcnt As Byte Dim Messagedata As Byte Messagedata = &B10011001 'CQ Writeeeprom Messagedata , 10 Messagedata = &B11101001 Writeeeprom Messagedata , 11 Messagedata = &B10110000 Writeeeprom Messagedata , 12 Messagedata = &B10010111 'DE Writeeeprom Messagedata , 13 Messagedata = &B01110000 Writeeeprom Messagedata , 14 Messagedata = &B01101010 'JN3XBY Writeeeprom Messagedata , 15 Messagedata = &B11100111 Writeeeprom Messagedata , 16 Messagedata = &B01010110 Writeeeprom Messagedata , 17 Messagedata = &B10111001 Writeeeprom Messagedata , 18 Messagedata = &B01101110 Writeeeprom Messagedata , 19 Messagedata = &B01010111 Writeeeprom Messagedata , 20 Messagedata = &B10011010 Writeeeprom Messagedata , 21 Messagedata = &B11111100 Writeeeprom Messagedata , 22 Messagedata = &B10011000 'K Writeeeprom Messagedata , 30 Messagedata = &B10011101 'NAME IS Writeeeprom Messagedata , 40 Messagedata = &B10111010 Writeeeprom Messagedata , 41 Messagedata = &B11011111 Writeeeprom Messagedata , 42 Messagedata = &B11010111 Writeeeprom Messagedata , 43 Messagedata = &B01010111 Writeeeprom Messagedata , 44 Messagedata = &B11110000 Writeeeprom Messagedata , 45 Messagedata = &B10111010 'TOSHI Writeeeprom Messagedata , 50 Messagedata = &B10110101 Writeeeprom Messagedata , 51 Messagedata = &B01110101 Writeeeprom Messagedata , 52 Messagedata = &B01011101 Writeeeprom Messagedata , 53 Messagedata = &B01111100 Writeeeprom Messagedata , 54 '*************************************************** '* EXTERNAL,REVERSE or INTERNAL KEY Judge '*************************************************** Keyina = Pina Keyina = Keyina And &B11111000 If Keyina = &B11111000 Then Goto Internalkeymain If Keyina = &B01111000 Then Goto Extkeymain Reverse_key: Readeeprom Revkey , 1 If Revkey = 0 Then Goto Rev_key Revkey = 0 Writeeeprom Revkey , 1 Goto Internalkeymain Rev_key: Revkey = 1 Writeeeprom Revkey , 1 Goto Internalkeymain '*************************************************** '* EXTERNAL KEY MODE '*************************************************** Extkeymain: Keyina = Pina Keyina = Keyina And &B11111000 If Keyina = &B10111000 Then Goto Keyon Gosub Keyreset_sub Goto Extkeymain Keyon: Gosub Keyset_sub Gosub Tone_sub Goto Extkeymain '*************************************************** '* INTERNAL ELEKEY MODE '*************************************************** Internalkeymain: Readeeprom Revkey , 1 Revkeymem = Revkey '*************************************************** '* TIMER INT ROUTINE INTIALIZE '*************************************************** Config Timer1 = Timer , Prescale = 1024 On Timer1 Tim1_isr Enable Timer1 Enable Interrupts '*************************************************** '++++++++++++++ Main Routine +++++++++++++++ Main: Dotleng = 10 Dashleng = 30 If Revkeymem = 0 Then Goto Key_speed Dotleng = 30 Dashleng = 10 '+++++++++++++++ Key Speed Routine +++++++++++++++ Key_speed: Start Adc Speed = Getadc(0) Stop Adc Keyleng = Speed / 8 'Speed Henka no Katamuki Keyleng = Keyleng + 40 'Max Speed Spaceleng = Keyleng 'Space no nagasa wo kettei Wspace = Keyleng * 2 '++++++++++++++ Key Input Routine +++++++++++++++ Keyina = Pina Keyina = Keyina And &B11111000 If Keyina = &B01111000 Then Gosub Dot If Keyina = &B10111000 Then Gosub Dash If Keyina = &B11101000 Then Gosub Memory1 If Keyina = &B11110000 Then Gosub Memory2 Goto Main '***************************************************** '* Message Memory Call SUBROUTINE '***************************************************** Memory1: For Loopcnt = 1 To 3 Memadress = 10 'CQ Gosub Memloop_sub Next Memadress = 13 'DE Gosub Memloop_sub For Loopcnt = 1 To 3 Memadress = 15 'JN3XBY Gosub Memloop_sub Next Memadress = 30 'K Gosub Memloop_sub Return Memory2: Memadress = 40 'NAME IS Gosub Memloop_sub For Loopcnt = 1 To 3 Memadress = 50 'TOSHI Gosub Memloop_sub Next Return Memloop_sub: Readeeprom Mem , Memadress Memdatacnt = 4 Memloop2: Dotleng = 10 Dashleng = 30 Keydata = Mem And &B11000000 Select Case Keydata Case &B01000000 : Gosub Dot Case &B10000000 : Gosub Dash Case &B11000000 : Waitms Wspace Case &B00000000 : Return End Select Rotate Mem , Left , 2 Memdatacnt = Memdatacnt - 1 If Memdatacnt > 0 Then Goto Memloop2 Memadress = Memadress + 1 Goto Memloop_sub '***************************************************** '* DOT/DASH SUBROUTINE '***************************************************** Dot: Keymem = 0 Keymode = 1 Toneleng = Keyleng * Dotleng 'Dot no nagasa wo kettei Goto Keyonoff Dash: Keymem = 0 Keymode = 2 Toneleng = Keyleng * Dashleng 'Dash no nagasa wo kettei Keyonoff: Toneloop = Toneleng / 14 Gosub Keyset_sub ' Stop Timer1 Toneloopl1: Gosub Tone_sub Toneloop = Toneloop - 1 If Toneloop > 0 Then Goto Toneloopl1 ' Start Timer1 Gosub Keyreset_sub Waitms Spaceleng Keymode = 0 If Keymem = 1 Then Goto Dash If Keymem = 2 Then Goto Dot Return Keyset_sub: Reset Portb.4 'MUTE ON Set Porta.1 'LED ON Set Portb.1 'Shift ON Waitms 1 Reset Portb.5 '*Key ON Set Portb.3 'Key ON Return Tone_sub: Set Portb.6 'Tone Output Port Waitus 730 'Tone Frequency(Time) no 1/2 Reset Portb.6 'Tone Output Port Waitus 730 Return 'Tone Frequency(Time) no 1/2 Keyreset_sub: Reset Portb.3 'Key OFF Set Portb.5 '*Key OFF Waitms 1 Reset Portb.1 'Shift OFF Reset Porta.1 'LED Off Set Portb.4 'MUTE OFF Return '***************************************************** '* Key Memory SUBROUTINE '***************************************************** Keymem: Tcnt = Tcnt + 1 If Tcnt < 8 Then Return Tcnt = 0 If Keymem > 0 Then Return Keyina = Pina Keyina = Keyina And &B11111000 If Keyina = &B01111000 Then Goto Keymeml2 'Keymemdot If Keyina = &B10111000 Then Goto Keymeml1 'Keymemdash If Keyina = &B00111000 Then Goto Keymeml3 Return Keymeml1: If Keymode = 1 Then Keymem = 1 'Keymode=1 -> Dot Return Keymeml2: If Keymode = 2 Then Keymem = 2 'Keymode=2 -> Dash Return Keymeml3: If Keymode = 1 Then Keymem = 1 If Keymode = 2 Then Keymem = 2 Return '***************************************************** '* TIMER INT COUNTER SUBROUTINE '***************************************************** Tim1_isr: Gosub Keymem Return '******************************************************