Define CONFIG = 0x3194
'Processor 12F675, internal 4Mhz clock
Define CLOCK_FREQUENCY = 4.0
'Program To check Icom band voltage/2 (now 0-4V) and check for 6M band
'If 6M selected, then any "send" (PTT) output for amplifier
'is routed to second "send" output for 6M
'Otherwise, all others go to regular HF "send"
'Note that send outputs are active high, needs 2N7000 to conduct
'to ground as PTT/Relay/Amp output to ground.
'Or, can power any relay taking less than 25Ma at 5V
'Need 10k pullup on GP3 (insend) input.
'GP0 is analog input, use precision 1% resistors
'to divide voltage by 1/2 (0-4V)
'6M band is between 1.2 to 2.0V and divide by 2 (count 30 to 51 for BYTE)
'(count 122 to 204 for WORD, if using WORD for "i")
'Set range check to one or two digits tighter bandwidth
ConfigPin GP0 = Input
ConfigPin GP3 = Input
ConfigPin GP1 = Output
ConfigPin GP2 = Output
ConfigPin GP4 = Output
ConfigPin GP5 = Output
AllDigital
'Alldigital will set CMCON to 0x07
'Will reset AN0 as analog later in ANSEL
Symbol hfled = GP1
Symbol vhfled = GP2
Symbol hfsend = GP4
Symbol vhfsend = GP5
Symbol insend = GP3
ANSEL = 0x31 '30 = internal clock, 1 is GP0 = AN0
ADCON0.VCFG = 0 'use VDD as reference (default anyway)
Dim i As Word
'Following is to read osccal value from 3FFF
'and insert into OSCCAL register
'RETLW instruction is 34xx where xx is value
'OSCCAL is not critical unless using software UART
ASM: bsf STATUS,RP0 ;bank 1
ASM: call 3ffh ;get the cal value
ASM: movwf OSCCAL ;calibrate
ASM: bcf STATUS,RP0 ;bank 0
hfsend = 0 'HF output =0
vhfsend = 0 'VHF output = 0
vhfled = 0
hfled = 1 'Default to HF LED on
WPU.0 = 0
loop:
'Main read loop. Takes about 88uS with BYTE
'but around 145uS with WORD variable (and word limits)
Adcin 0, i
Select Case i
Case < 122, > 205 'HF
hfled = 1
vhfled = 0
Case Else 'VHF (6M)
hfled = 0
vhfled = 1
EndSelect
If insend = 1 Then Goto loop 'No action on send pin, go back and read over and over
'if we get here, send is set to zero (grounded). Time to output a pin
'No debounce done, assume input is solid state from radio
'If there is bounce, we will bounce along with it...
'Determine action based on which LED is on
If hfled = 1 Then
hfsend = 1
vhfsend = 0
Else
hfsend = 0
vhfsend = 1
Endif
loop2:
If insend = 0 Then Goto loop2 'loop forever until send pin clears (goes high)
'Send clear, clear send outputs
hfsend = 0
vhfsend = 0
Goto loop