The repeater controller I was working on with AVR's BASCOM has taken shape for the time being! However, compiling this code with the BASCOM trial version will result in an error because it exceeds 4KB. There is only one mode of TIMEOUT and only one mode in which TIMEOUT is reset in case of hang-up
This source code is tailored to the ATMEGA88.
input-output PB2-8 Output for LCD (20x4) PD0 For setup + Input PD1 for setup - Input For PD2 Setup Next Item Entry PC1 Squelch input PC2 Setup mode Input PC3 Operation mode Input PC4 CW tone 0 to +5V only Input PC5 PTT output
Dim I3 As Byte Declare Sub Modeselect1() Declare Sub Lcdvalue() Declare Sub Lcddisp() Declare Sub Repeater() 'Declare Sub Cw()
Dim Cwf As Byte
Dim Maxline As Byte
Dim Setupvalue(22) As Byte $default Eram Dim Eeprom_value(22) As Eram Byte At $01 $default Sram Dim Sw(4) As String * 3 Dim Modeselect As Byte Dim Modechar(5) As String * 20 Dim Page As Byte Dim Flag As Bit ' Timer 1Hz Dim Timeout As Byte
Main: Main Do Debounce Pinc.3 , 1 , Setup , Sub Debounce Pinc.3 , 0 , Repeater , Sub loop End
Sub Repeater() Local Timer_1 As Byte Local Timer_2 As Byte Local Timer_3 As Byte Local S1 As String * 2 Local Fstep As Byte Local Hungup As Byte 'Dim Timeout As Byte
Fstep = 0 Cwf = 0 If Eeprom_value(1) = &HFF Then Eeprom_value(1) = 1 If Eeprom_value(2) = &HFF Then Eeprom_value(2) = 1 If Eeprom_value(3) = &HFF Then Eeprom_value(3) = 1 If Eeprom_value(4) = &HFF Then Eeprom_value(4) = 1 Timer_1 = Eeprom_value(1) Timer_2 = Eeprom_value(2) * 10 Timer_3 = Eeprom_value(3) Cls.
Do Select Case Fstep
Case 0 If Pinc.1 = 0 Then Reset Portc.5 Hungup = 0 Timeout = 0 Fstep = 1 End If
Case 1 If Timeout = Timer_2 Then Fstep = 4 End If If Timeout <= Timer_2 Then Timeout = Timeout + 1 S1 = Str(timeout) Cls : Locate 1 , 1 : Lcd "PTT ON" : Lcd Format(s1 , " ") If Cwf = 0 Then Gosub Cw1 Wait 1 End If If Pinc.1 = 1 Then Fstep = 2
'Hungup count Case 2 If Pinc.1 = 1 Then Locate 1 , 1 : Lcd "Hungup " If Eeprom_value(4) = 2 Then Timeout = Timeout + 1 If Hungup = Timer_1 Then Fstep = 3 Hungup = 0 End If
If Hungup <= Timer_1 Then Hungup = Hungup + 1 Wait 1 End If If Pinc.1 = 0 Then ' Hungup = 0 Fstep = 0 End If End If
' Hungup Case 3 Set Portc.5 Cls : Locate 1 , 1 : Lcd "PTT OFF " Fstep = 0 Cwf = 0 ' Timeout Case 4 Set Portc.5 Cls : Locate 1 , 1 : Lcd "PTT OFF Timeout" Timeout = 0 Hungup = 0 Fstep = 0 ': S1 = 0 Wait Timer_3 Cls : Locate 1 , 1 : Lcd "PTT OFF " Cwf = 0 End Select
Debounce Pinc.3 , 1 , Endofloop
loop
Endofloop:. 'Disable Oc0a 'Disable Interrupts End Sub
Cw1:. Cwf = 1 Dim In_char As String * 1 Dim M_data As String * 5 Dim M As String * 1 Dim Cwlen As Byte Dim Cwcodelen As Byte Cls. For Cwlen = 1 To Len(modechar(5)) Locate 2 , Cwlen Lcd Mid(modechar(5) , Cwlen , 1) In_char = Mid(modechar(5) , Cwlen , 1)
If In_char = " " Then M_data = " " If In_char = "A" Then M_data = "0-" If In_char = "B" Then M_data = "-000" If In_char = "C" Then M_data = "-0-0" If In_char = "D" Then M_data = "-00" If In_char = "E" Then M_data = "0" If In_char = "F" Then M_data = "00-0" If In_char = "G" Then M_data = "--0" If In_char = "H" Then M_data = "0000" If In_char = "I" Then M_data = "00" If In_char = "J" Then M_data = "0---" If In_char = "K" Then M_data = "-0-" If In_char = "L" Then M_data = "0-00" If In_char = "M" Then M_data = "--" If In_char = "N" Then M_data = "-0" If In_char = "O" Then M_data = "---" If In_char = "P" Then M_data = "0--0" If In_char = "Q" Then M_data = "--0-" If In_char = "R" Then M_data = "0-0" If In_char = "S" Then M_data = "000" If In_char = "T" Then M_data = "-" If In_char = "U" Then M_data = "00-" If In_char = "V" Then M_data = "000-" If In_char = "W" Then M_data = "0--" If In_char = "X" Then M_data = "-00-" If In_char = "Y" Then M_data = "-0--" If In_char = "Z" Then M_data = "--00" If In_char = "0" Then M_data = "-----" If In_char = "1" Then M_data = "0----" If In_char = "2" Then M_data = "00---" If In_char = "3" Then M_data = "000--" If In_char = "4" Then M_data = "0000-" If In_char = "5" Then M_data = "00000" If In_char = "6" Then M_data = "-0000" If In_char = "7" Then M_data = "--000" If In_char = "8" Then M_data = "---00" If In_char = "9" Then M_data = "----0" If In_char = "/" Then M_data = "-00-0"
For Cwcodelen = 1 To Len(m_data) If Mid(m_data , Cwcodelen , 1) = "0" Then Sound Portc.4 , 100 , 100 If Mid(m_data , Cwcodelen , 1) = "-" Then Sound Portc.4 , 300 , 100 If Mid(m_data , Cwcodelen , 1) = " " Then Waitms 80 Waitms 30 Next Waitms 200 Next
Return
Setup: 1.
Set Portc.5 Gosub Lcddisp Do
Debounce Pind.0 , 0 , Sw0on , Sub Debounce Pind.1 , 0 , Sw1on , Sub Debounce Pind.2 , 0 , Modeselect1 , Sub Debounce Pinc.3 , 0 , Endofsetup loop Endofsetup:. Return End
Sub Lcddisp() Local I As Byte Local I2 As Byte Local I1 As Byte Cls.
For I = 1 To Maxline I2 = Page - 1 I2 = Maxline * I2 I1 = I + I2 Setupvalue(i1) = Eeprom_value(i1) If Setupvalue(i1) = 255 Then Setupvalue(i1) = 1 End If