Software

Software Evolution

The TAK-40 is controlled by a Microchip 16F871 MCU.
As the TAK-40 has developed, two branches of software exist. When the TAK-40 was introduced in the ARRL Home Brew Challenge it was presented with an analog VFO. This design, along with other construction techniques allowed the radio to be constructed below the $50(USD) budget. In fact, all the current board sources including Express PCB, Far Circuits and KD8DFL include the PC board for the VFO. After discussions in the ARRL Home Brew Challenge Yahoo Group enhancements were made to the TAK-40 including RF Gain, and an audio amplifier.

Original design constraints

Some of the complaints of the analog VFO was a noticeable tendency to drift. While not a great issue for SSB/CW operation it made digital modes very challenging.

Improvements

K0DKT and WA2EUJ investigated the possibility of replacing the analog VFO with a Direct Digital Synthesis (DDS) module to improve stability, and have done so with the optional DDS-60 kit from AMQRP.org. This necessitated wiring and software changes, but resulted in an extremely stable VFO able to use digitial modes successfully. While moving from the analog VFO to the DDS module improved frequency stability, the DDS does also have to have a connection to the digital board for control.

To facilitate the use of the DDS card, WA2EUJ released a new version of the software, which also added RIT to the transceiver.

Hi Everyone,

I just used my TAK-40 to make a PSK-31 contact. It was the 250th
anniversary of Pittsburgh special events station WA3COM/250 and
granted Baltimore to Pittsburgh isn't really impresive, I got a kick
out of using the TAK-40 on PSK-31.

Here are a few component changes that help make the steps that the
BFO makes less noticable. It's probably handy for CW as well.

Change To
C104 27pf This decreases the BFO range and shrinks
the step size.
R131 22k
C108 1uF This makes the steps slower (easier to track)

It takes a bit longer to change from USB/CW to LSB but if you are
interested in PSK-31 this will help.

73's
Jim WA2EUJ

Current Software

The current software released includes all of the changes made by Jim WA2EUJ.

++TAK-40 with Bootloader.HEX (July 4th, 2008)

:020000040000FA
:0600000088018901F12EC8
:02000800792954
:04000C008316031341
:100010002F308500F03086008130870002309F004D
:10002000D7308100FF309200831291309F0007305B
:10003000900088308B000130B700D9000C30970059
:10004000A030950004309200FF30DD00AB01C80104
:10005000C901CD01CE01D701D801CA01CB01CC0124
:10006000DA01E101E201E501E801861406118611D9
:1000700099308700FA30F12766250C30F1002B22E9
:100080008710721887140D30F1002B22720807397F
:1000900003190230D60006104925042387224B1489
:1000A00006080B100B17A51F9C2B4B1C59284B1037
:1000B000F12156186528611C6528E1010130DF2710
:1000C0003230F127E5016814042356186E28061C07
:1000D0006E280930E700E524E70B6B28561C8B28B7
:1000E000611C8B28E50187160530F1278712E5246E
:1000F000AA1F73286110FA30E2001C30F127E524B2
:10010000AA1F7328E20B7D280130DF273230F12748
:100110006814061004230618D6282508A600B5275B
:1001200025082606B300C830F127331EA628251E51
:10013000D62894224B14023087060C30F10001308F
:1001400087180030F2003722DE22D628B31EAD28F1
:10015000A51ED6285E22CC22D628B31FBC28A51FF8
:10016000D6282D08B4002C08B5002E08B60074223D
:10017000B6224B14D422D628B31CC428A51CD628DA
:100180000230CB06EF22D628331DD628251DD628CF
:100190000310D60DD61DCE280130D60049250423E4
:1001A0000D30F1005608F2003722D6280618122921
:1001B00095309F001F19DA2803109E0C44309E02D0
:1001C000031C9E0140250038031D12291430CB2743
:1001D0000230DF000330E0000730DE0002301E0294
:1001E000031C09296008CE279E039E0BF8280E29C0
:1001F0009E0BFB2809296008CE27DE0B0029122957
:1002000005305E02031DF5280130DF00A030E0005C
:10021000F5285F08CE27DE03031912292030CE27E8
:10022000DE0B0E29371C22298E018F0107120230A6
:10023000B7001430C700C70B1B293D3081000B11DC
:100240008B167729B71D7729B71C39290E08B800F6
:100250000F08B900BA018E018F0187110430B70071
:100260001430C700C70B32293D3081000B118B16AB
:1002700077290130B7000E084D0203194B290E08EB
:100280004E0203194B294D08CE000E08CD000E0872
:10029000CF000F08D0004F0803195329B8070318DF
:1002A000B90A0319BA0A5008B9070318BA0ACA08E2
:1002B00003195D29CA0B5D294E22CC080319632955
:1002C000CC0B77297129681871293808480203195D
:1002D000772938084902031977294808C9003808DE
:1002E000C800681040250038031D7729382393245F
:1002F0005528F000030E8301A7008B130B1D8729DF
:1003000018308704B7158B120B113716EC29060825
:10031000AA002B06B200321E9529AA1A92292A1A7F
:10032000BB299F292A1EBB299F29B21ED429AA1A9C
:100330009C292A1A9F29BB292A1E9F29BB291330D1
:100340005A05031DB329CB18A929AE0AAE1DD2291F
:10035000AE01AC0A0319AD0A2D1ED2290F30AD0033
:10036000FF30AC00D229DB0A0319DB094B17E9295E
:10037000DB034B17E92913305A05031DB829CB18A5
:10038000C629AE08031DD1290730AE00AC080319F9
:10039000AD03AC032D03031DD2290230AD00AC0127
:1003A000D229AE034B14E929C830E400A530E3009C
:1003B000E30BD829E40BD629321FDF29E929B21F24
:1003C000E9296114861FE729561C0610E92906143D
:1003D000E9290B102A08AB00270E8300F00E700EDF
:1003E00009008610061186110830B1008B112D0806
:1003F0003F39303820220830B1002C0820228614E2
:10040000061186112D08A9002C082E07A800031834
:10041000A90A291E0E2AFF30A900A8008B158610F4
:100420000830B1002908BF39B03820220830B100A7
:10043000280820228614061186113230CA000800CE
:10044000B000B01F8611B01B861506150611B00D41
:10045000B10B212A08000317831271088D0083163F
:100460008C130C1483120C08F2000313080083167B
:1004700003178C18392A831271088D0072088C00BA
:1004800083168C130C158B1355308D00AA308D00FC
:100490008C148B170C118312031308000930F10020
:1004A0002D08F20037220A30F1002C08F200372222
:1004B0000B30F1002E08F200372208000030F10066
:1004C000871CF10A2D08F20037220230F100871C48
:1004D000F10A2C08F20037220430F100871CF10ADF
:1004E0002E08F200372208000030F100871CF10AC4
:1004F0002B22AD000230F100871CF10A2B22AC0048
:100500000430F100871CF10A2B22AE0008000930EC
:10051000F1002B22AD000A30F1002B22AC000B3091
:10052000F1002B22AE0008002D08B4002C08B50005
:100530002E08B6000630F1002B22AD000730F10086
:100540002B22AC000830F1002B22AE000630F10067
:100550003408F20037220730F1003508F200372264
:100560000830F1003608F200372208000030F100B0
:10057000871CF10A3408F20037220230F100871C90
:10058000F10A3508F20037220430F100871CF10A25
:100590003608F2003722080032235630CE271A30B0
:1005A000CE274D30CE27292B32235330CE2777301C
:1005B000CE276130CE277030CE272B2B32235630FA
:1005C000CE274630CE274F30CE272030CE27871873
:1005D000EC2A4230CE272D2B4130CE272D2B322333
:1005E000CB18FB2A5330CE276C30CE276F30CE2766
:1005F0007730CE272B2B4630CE276130CE27733075
:10060000CE277430CE272B2B32230830CB27061C65
:10061000102B5430CE275830CE272030CE2708005C
:10062000561C192B4330CE275730CE272030CE27EB
:100630000800D61C222B5530CE275330CE2742300F
:10064000CE2708004C30CE275330CE274230CE275D
:1006500008002030CE272030CE272030CE2708308B
:10066000CC0008000230DF278B120130B7000800F1
:100670000230DF273A08BB003908BC003808BD004B
:10068000BE012730BF001030C0005C23BE01033024
:10069000BF00E830C0005C23BE01BF016430C00071
:1006A0005C23BE01BF010A30C0005C232E30CE2780
:1006B0004308303ECE2708001830C7003B08C4006E
:1006C0003C08C5003D08C600BB01BC01BD01C1011D
:1006D000C201C3010310C60DC50DC40DC30DC20D6B
:1006E000C10D3E084102031D7B2B3F084202031D42
:1006F0007B2B40084302031C8D2B4008C3020318C8
:10070000862BC2034208FF3A0319C1033F08C20205
:10071000031CC1033E08C1020314BD0DBC0DBB0D7B
:10072000C70B6A2B30303D07CE274108BB0042087B
:10073000BC004308BD000800CB141030DA00371CA1
:10074000B52B8E018F015A080C39031DA92B871177
:10075000AA2B07120230B7001430C700C70BAE2B0C
:100760003D3081000B118B16C52BB71DC52B0130F9
:10077000B70002300E02B8000F08031C0F03B900C7
:10078000BA012030CB06CB1E382310305A0503198E
:1007900093244B1CCD2B4B10F1212508A600B52727
:1007A00025082606B300FA30F127B31FE12BA51F59
:1007B000F12B0310DA0DDA1EDF2B0130DA003724BB
:1007C000F12B331CF12B251CF12B5A1CE92B123079
:1007D000EC2BDA1CF12B1030F1005B08F200372211
:1007E00037244B1F2E2C4B131430CB275A1E012CB1
:1007F00033305B020318FE2B3330DB005B089500BF
:100800002E2C9D305B02BD000030031C0130093EE0
:100810005202BC000630BB000130BE008630BF0073
:10082000A030C0005C23BE012730BF001030C000E4
:100830005C23BE010330BF00E830C0005C23BE0172
:10084000BF016430C0005C232E30CE27BE01BF0143
:100850000A30C0005C234308303ECE279F2BDC00CB
:100860000A305C020318073E3A3ECE2708000130EA
:10087000DF27FA30F1278B120130B7000830CB2781
:100880005A1C542C4230CE274630CE274F30CE272C
:100890002030CE274C30CE275330CE274230CE27C3
:1008A0000430D60049250800DA1C682C4230CE27D7
:1008B0004630CE274F30CE272030CE275530CE279A
:1008C0005330CE274230CE270230D60049250800CB
:1008D0005A1D742C87144C30CE274F30CE27203031
:1008E000CE274130CE278C2CDA1D802C87104C303F
:1008F000CE274F30CE272030CE274230CE278C2C2B
:100900004230CE274630CE274F30CE272030CE275C
:100910000230D60049258C2C0B30C7002030CE2762
:10092000C70B8E2C0800371CE42C371218308704B4
:100930008E018F010A30D50087116430F127D50B65
:100940009D2C8715371AE42C0E0857020319E42C46
:100950000E0858020319E42C5708D8000E08D700D7
:1009600052080F020319B72C0318CA2CC12C5108C6
:100970000E020319E42C0318C62C51030E020319AE
:10098000E42C4030D3070318D40ACE2C510A0E02AF
:100990000319D82C4030D302031CD4035308D500CC
:1009A000D50CD50C0C305504970054089500E42C58
:1009B0004B1DE42C4B11561DDF2C0E30E02C0F305C
:1009C000F1005408F20037220800E508031DF52C59
:1009D000E50AA1309F001430CB27A5309F00E60127
:1009E0001F19F02C1E08E6000800651CFE2C0310E1
:1009F000E50D10306602031C3A2D3D2DE51C072D38
:100A00000310E50D30306602031C3A2D3D2D651DA7
:100A1000102D0310E50D50306602031C3A2D3D2DBC
:100A2000E51D192D0310E50D70306602031C3A2DEB
:100A30003D2D651E222D0310E50D90306602031C2E
:100A40003A2D3D2DE51E2B2D0310E50DB03066022D
:100A5000031C3A2D3D2D651F342D0310E50DD030BC
:100A60006602031C3A2D3D2DE501F0306602031CA1
:100A70003A2D3D2D4F30CE2708000030CE270800FC
:100A80008316FF30880083120809831688018312B9
:100A900008004B15561D552D2430D2001230F100A0
:100AA0002B227208D1000E305D2D2330D200103081
:100AB000F1002B227208D1000F30F1002B227208B6
:100AC000D40095005108DB004B170800A030DF2749
:100AD0000030CE270E30CE271F30CE271F30CE2736
:100AE0001F30CE271F30CE270E30CE270030CE2726
:100AF0000030CE271830CE271830CE271830CE271A
:100B00001830CE271830CE271830CE271830CE27F1
:100B10000030CE270030CE270030CE271830CE2729
:100B20001830CE271830CE271830CE271830CE27D1
:100B30000030CE270030CE270030CE271B30CE2706
:100B40001B30CE271B30CE271B30CE271B30CE27A5
:060B5000E030DF27080081
:100DE000F02E8316003089008312FA30F127B527E0
:100DF000A527251806282930A8000230DF27423011
:100E0000CE274C30CE278F2711309F2799273A3A8B
:100E1000031D062FAC017F271F39AB000310AB0C5D
:100E20007F27A9007F27AA000310A90CAA0C7F27FF
:100E3000013A03196D2F2F08003A031D622FE0308D
:100E400029070318622F313084002B08AD007F275B
:100E50008000840A7F278000840AAD0B272F7F271C
:100E60002C08031D762F313084002B08AD0006308E
:100E70002902031C412F031D762FF0302A0203188C
:100E8000762F2908831203178F0003132A080317EC
:100E90008D0000088C00840A00088E00840A8316E6
:100EA00084308C0055308D00AA308D008C140000E9
:100EB000000083120313AA0F602FA90A62309F2734
:100EC000AD0B372F0130DF270230DF270130A806B6
:100ED0002808CE272E309F27062F0130DF2702302B
:100EE000DF275330CE2753309F27752F0130DF2760
:100EF0000230DF274630CE2746309F277E2F9927A6
:100F0000BF3E031C073E0A3EAF00AF0E9927BF3E0F
:100F1000031C073E0A3EAF042F08AC0708008316E7
:100F20008130990018151812981683121816981700
:100F30000800831203138C1E9B2F1A0808008312CB
:100F400003130C1EA12F990008008901FA30F12724
:100F50001C30DF271430DF272830DF274F30DF2712
:100F60000130DF27FA30F127080083160313FF3022
:100F7000880083120808A5008316880183120800E0
:100F80008316FF30880083120809031DC42F8316BF
:100F9000880183120800E038DF270800A000C0277E
:100FA00004308900F62705308900200800008800F9
:100FB000F6270430890089010530F1270800A000D8
:100FC000C02701308900F627200800008800F62796
:100FD00089010530F1270800A530A300A30BEE2FEF
:100FE0000800A400EC27A40BF22F0800000000006A
:040FF00000000800F5
:02400E00713F00
:00000001FF

TAK-40 with Callsign (July 18, 2008)

This includes TAK40.asm and TAK_MSG.asm

#include <p16f871.inc>
                ERRORLEVEL -224        ;  suppress annoying message because of tris

;=============================================================================
;    Filename:    TAK40.asm
;=============================================================================
;    Author:        Jim Veatch
;    Callsign:    WA2EUJ
;    Revision:    1.00
;    Date:        11 Noveber 2006
;    Assembled using MPASM V7.20
;=============================================================================
;    Include Files:    p16f871.inc    
;=============================================================================
;    
;=============================================================================
BAUD_9600        equ    0x81                    ;ASYNC port baud rate 9600
BAUD_19200        equ    0x40                    ;ASYNC port baud rate 19200
BAUD_CONSTANT    EQU    BAUD_9600                ;Constant for baud generator for 19200 baud
;     STATUS bit definitions
                #define    _C        STATUS,0
                #define    _Z        STATUS,2
;Fosc is 20MHz
;
;These Values are for the 24X1 Display
GetHexByte        equ    0x077f                    ; Rcvs two ASCII digits and converts into one HEX byte in W
LCD_CLEAR        equ    0x01                    ; Clear the display
LCD_HOME        equ    0x02                    ; Cursor Home
LCDPUTCHAR      equ    0x7CE                    ; Sends character in W to LCD for display                    
LCDPUTCMD       equ    0x7DF                    ; Sends character in W to LCD command register
LCDSDDA         equ    0x7CB                    ; Takes DD Address in W and sets DD address in LCD display
SerialReceive    equ    0x0799                    ; Waits for an incoming byte, returns with the byte in W
SerialTransmit    equ    0x079f                    ; Waits for the serial TX buffer to empty and sends the byte in W
FP_READ            equ    0x07b5                    ; Reads the front panel switches and stores in FP_Switch
X_DELAY100        equ    0x07f1                    ; Generates a delay of W*100 uSec

W_TEMP            equ    0x70                    ; Bank Independant storage for W
EE_ADDR            equ    0x71                    ; EEPROM R/W Address storage
EE_DATA            equ    0x72                    ; EEPROM R/W Data storage
SELECT            equ    0x00                    ; Select pushbutton
;RATE            equ    0x01                    ; Rate pushbutton
MODE            equ    0x02                    ; Mode pushbutton
TUNE            equ    0x03                    ; Tune pushbutton
VFO_AB            equ    0x04                    ; VFO A/B pushbutton
V2M            equ    0x05                    ; VFO to MEMORY pushbutton
M2V            equ    0x06                    ; MEMORY to VFO pushbutton
SWAP            equ    0x07                    ; SWAP pushbutton
VA_HI            equ    0x00                    ; EEPROM Location for VFO A MSB
VB_HI            equ    0x01                    ; EEPROM Location for VFO B MSB
VA_LO            equ    0x02                    ; EEPROM Location for VFO A LSB
VB_LO            equ    0x03                    ; EEPROM Location for VFO B LSB
VA_OS            equ    0x04                    ; EEPROM Location for VFO A Offset
VB_OS            equ    0x05                    ; EEPROM Location for VFO B Offset
SC_HI            equ    0x06                    ; EEPROM Location for scratch MSB
SC_LO            equ    0x07                    ; EEPROM Location for scratch LSB
SC_OS            equ    0x08                    ; EEPROM Location for scratch Offset
CR_HI            equ    0x09                    ; EEPROM Location for current MSB
CR_LO            equ    0x0a                    ; EEPROM Location for current LSB
CR_OS            equ    0x0b                    ; EEPROM Location for current Offset
VFAB            equ    0x0c                    ; EEPROM Location for BAND
OPMD            equ    0x0d                    ; EEPROM Location for OPMODE
BFO_L            equ    0x0e                    ; EEPROM Location for LSB BFO PWM word
BFO_U            equ    0x0f                    ; EEPROM Location for USB BFO PWM word
BFO_USB            equ    0x10                    ; EEPROM Location for USB Counter LSB
BFO_LSB            equ    0x12                    ; EEPROM Location for LSB Counter LSB
NOT_CTNG        equ    0x00                    ; Not Counting BIT
CTNG_LO            equ    0x01                    ; Counting LO bit
CTNG_BF            equ    0x02                    ; Counting BFO bit
DONE_CTNG        equ    0x03                    ; Counting Finished
ISR_RUN            equ    0x04                    ; ISR messed up the count
MSB            equ    7
LSB            equ    0
UPDATE_FR        equ    0                        ; SSTAT: Update frequency flag
RATE            equ    1                        ; SSTAT: Tuning Rate Flag
BFO_SEEK        equ    2                        ; SSTAT: BFO Tuning Flag
SEL_KEY            equ    3                        ; SSTAT: Select Key Active
SEL_SET            equ    4                        ; SSTAT: Setup Key Active
S_CNT            equ    5                        ; SSTAT: Alternating Count Display Bit
WHL            equ    6                        ; SSTAT: Wheel Update Flag
SM            equ    7                        ; SSTAT: TX

;Variables in bank0

        CBLOCK    0x20
        LCD_TEMP:        1                    ; [20] LCD subroutines internal use
        TABLE_INDEX:        1                    ; [21] Index to table strings
        COUNT:            1                    ; [22] A counter
        DELAY:            1                    ; [23] Used in DELAYxxx routines
        X_DELAY:        1                    ; [24] Used in X_DELAYxxx routines
        FP_Switch:        1                    ; [25] Front Panel Switch State
        PREV_FP:        1                    ; [26] Previous state of FP switched
        STAT_TEMP:        1                    ; [27] Interrupt Storage for STATUS Register
        TEMP_LO:        1                    ; [28] 16 Bit LO Temp storage
        TEMP_HI:        1                    ; [29] 16 Bit HI Temp storage
        CURR_B:            1                    ; [2A] Current state of PORT B
        PREV_B:            1                    ; [2B] Previous state of PORT B
        FREQ_LO:        1                    ; [2C] LO Frequency LSB
        FREQ_HI:        1                    ; [2D] LO Frequency MSB
        FREQ_OST:        1                    ; [2E] LO Frequency Offset
        FREQ_STP:        1                    ; [2F] Frequency step
        ROT_TEMP:        1                    ; [30] Data Shifter
        ROT_COUNT:        1                    ; [31] Data Counter
        I_TEMP:            1                    ; [32] Temporary storage for Interrupt Routine
        FP_TEMP:        1                    ; [33] Temporary storage for FP switch routine
        TP_HI:            1                    ; [34] Temporary storage for frequency word H
        TP_LO:            1                    ; [35] Temporary storage for frequency word M
        TP_OS:            1                    ; [36] Temporary storage for frequency word L
        CNT_STAT:        1                    ; [37] Frequency Conter Status
        C_FREQL:        1                    ; [38] Results of frequency counter H
        C_FREQM:        1                    ; [39] Results of frequency counter M
        C_FREQH:        1                    ; [3A] Results of frequency counter L
        nratorH:        1                    ; [3B] Divide numerator H
        nratorM:        1                    ; [3C] Divide numerator M
        nratorL:        1                    ; [3D] Divide numerator L
        denomH:            1                    ; [3E] Divide denominator H
        denomM:            1                    ; [3F] Divide denominator M
        denomL:            1                    ; [40] Divide denominator L
        remainH:        1                    ; [41] Divide remainder H
        remainM:        1                    ; [42] Divide remainder M
        remainL:        1                    ; [43] Divide remainder L
        shiftH:            1                    ; [44] Divide shifter H
        shiftM:            1                    ; [45] Divide shifter M
        shiftL:            1                    ; [46] Divide shifter L
        BCount:            1                    ; [47] Divide Routine Counter
        LAST_F1:        1                    ; [48] LSB of last freq count
        LAST_F2:        1                    ; [49] LSB of next to the last count
        FREQ_STORE:        1                    ; [4A] Counter to store the dial freq
        SSTAT:            1                    ; [4B] Software status register
        DISP_DELAY:        1                    ; [4C] Pause to display status counter
        LAST_B1:        1                    ; [4D] LSB of last BFO freq count
        LAST_B2:        1                    ; [4E] LSB of next to the last BFO count
        L0CT1:            1                    ; [4F] LSB of BFO freq count
        LOCT2:            1                    ; [50] MSB of BFO freq count
        BFO_FRL:        1                    ; [51] LSB of Desired BFO Freq
        BFO_FRH:        1                    ; [52] MSB of Desired BFO Freq
        BFO_STL:        1                    ; [53] LSB of Desired BFO Freq
        BFO_STH:        1                    ; [54] MSB of Desired BFO Freq
        HIRES_TEMP:        1                    ; [55] Loop counter
        OPMODE:            1                    ; [56] Mode Bit0 = CW, Bit1 = USB Bit2 = LSB
        LAST_BF1:        1                    ; [57] LSB of last BFO freq count
        LAST_BF2:        1                    ; [58] LSB of next to the last BFO count
        SEL_FNC:        1                    ; [59] Select Function 0=RIT, 1=PBT
        SET_FNC:        1                    ; [5A] Setup Function
        WHEEL:            1                    ; [5B] BFO setting wheel
        ACount:            1                    ; [5C] A2D digit counter
        PREV_A2D:        1                    ; [5D] Previos A2D reading
        CCount:            1                    ; [5E] A2D digit counter
        L_ONE:            1                    ; [5F] S-METER Single Chararacter
        L_TWO:            1                    ; [60] S-METER Dual Chararacter
        DISP_FLAG:        1                    ; [61] Display Update Flag
        TX_DELAY:        1                    ; [62] CW Key Delay
        IDELAY:            1                    ; [63] Key Bounce Delay Counter
        IXDELAY:        1                    ; [64] Key Bounce Delay Counter
        TXM_STAT:        1                    ; [65] TX Meter Status
        TXM_DATA:        1                    ; [66] TX Meter Data
        TXM_CNTR:        1                    ; [67] TX Meter Digit Counter
        FORCE_D:        1                    ; [68] Forces frequency display
        ENDC
;
;Interrupt Service Vector
                org    0x04
                goto     INT_CODE

                org    0x06
START                                        ; POWER_ON Reset (Beginning of user program)
;
; Initialize I/O ports, A/D converter and Timers
                include     "tak-ports.asm"

;*****************************************************************************
; Clear the display
;*****************************************************************************

                movlw    .250
                call    X_DELAY100
;
; Recall Mode Band and Frequency
;

MAIN:
                call    CG_DATA                ; Setup Special Characters

                movlw    VFAB                ; Restore VFO A/B setting
                movwf    EE_ADDR
                call    EE_READ
                bcf     PORTC,1
                btfsc    EE_DATA,0
                bsf     PORTC,1

                movlw    OPMD                ; Restore OP Mode
                movwf    EE_ADDR
                call    EE_READ
                movf    EE_DATA,W
                andlw    0x07
                btfsc    _Z
                movlw    0x02
                movwf    OPMODE
                bcf    PORTB,0                ; RX mode
                call    SET_OP_MODE
                call    LCD_MODE

                call    RECALL_CUR            ; Recall Frequency
                bsf    SSTAT,UPDATE_FR

                movf    PORTB,W
                bcf    INTCON,RBIF
                bsf    INTCON,PEIE            ; Enable Peripheral Interrupts

                btfss    FP_Switch,SWAP        ; Look for SWAP (SETUP) button press
                goto    SETUP                ; If not pressed START main code code

                call    LCD_CALL            ; Display Call Sign    
                movlw    .24
                movwf    DISP_DELAY

LOOP:
;
; Update Frequency?
                btfss    SSTAT,UPDATE_FR
                goto    F_UPDATE_END
                bcf    SSTAT,UPDATE_FR
                call    LO_FREQ
F_UPDATE_END:
;
                btfsc    OPMODE,0            ; Skip this process if CW
                goto    DISP_END
                btfss    DISP_FLAG,0
                goto    DISP_END
                clrf    DISP_FLAG
                movlw    LCD_CLEAR
                call    LCDPUTCMD
                movlw    .50
                call    X_DELAY100
                clrf    TXM_STAT
                bsf    FORCE_D,0
                call    LCD_MODE
DISP_END:
;
; TX Watt meter
                btfsc    OPMODE,0            ; Skip this process if CW
                goto    WMETER_END
                btfss    PORTB,0
                goto    WMETER_END            ; Skip wattmeter if receiving
                movlw    0x09
                movwf    TXM_CNTR
WMETER_LP:
                call    TX_METER
                decfsz    TXM_CNTR,F
                goto    WMETER_LP
WMETER_END:
;
; CW Transmit Processor
                btfss    OPMODE,0
                goto    CW_END
                btfss    DISP_FLAG,0            ; Check for state change
                goto    CW_END
                clrf    TXM_STAT

CW_KEY_LP:
                bsf    PORTC,5
                movlw    .5
                call    X_DELAY100
                bcf    PORTC,5
                call    TX_METER
;                movlw    .1
;                call    X_DELAY100
                btfss    CURR_B,7
                goto    CW_KEY_LP
                bcf    DISP_FLAG,0
                movlw    .250
                movwf    TX_DELAY            ; TX Hold Up
CW_DECAY:
                movlw    .28
                call    X_DELAY100
                call    TX_METER
                btfss    CURR_B,7
                goto    CW_KEY_LP
                decfsz    TX_DELAY,F
                goto    CW_DECAY
CWU_UNK:
                movlw    LCD_CLEAR
                call    LCDPUTCMD
                movlw    .50
                call    X_DELAY100
                bsf    FORCE_D,0
                bcf    PORTB,0
                call    LCD_MODE
CW_END:
;
; Front Panel Switch Processor
FP_ROUTINE:
                btfsc    PORTB,0
                goto    END_FP_SW
                movf    FP_Switch,W            ; Save last state
                movwf    PREV_FP
                call    FP_READ                ; read current state
                movf    FP_Switch,W            ; Get current state
                xorwf    PREV_FP,W            ; Look For Changes
                movwf    FP_TEMP                ; Save Result

                movlw    .200
                call    X_DELAY100            ; Wait 20 msec for switch bounce                
                btfss    FP_TEMP,VFO_AB            ; VFO A/B Switch
                goto    NOT_VFO_AB    
                btfss    FP_Switch,VFO_AB        ; Process on button up
                goto    END_FP_SW
                call     SWAP_SC
                bsf    SSTAT,UPDATE_FR
                movlw    0x02                ; Invert BIT 1
                xorwf    PORTC,F                ; Toggle VCO range
                movlw    VFAB
                movwf    EE_ADDR
                movlw    0x01
                btfsc    PORTC,1
                movlw    0x00
                movwf    EE_DATA
                call    EE_WRITE
                call    LCD_VFO                
                goto    END_FP_SW
NOT_VFO_AB:
                btfss    FP_TEMP,V2M            ; VFO to MEMORY Switch
                goto    NOT_V2M
                btfss    FP_Switch,V2M        ; Process on button up
                goto    END_FP_SW
                call    STORE_VFO
                call     LCD_STORE
                goto    END_FP_SW
NOT_V2M:
                btfss    FP_TEMP,SWAP        ; SWAP Switch
                goto    NOT_SWAP
                btfss    FP_Switch,SWAP        ; Process on button up
                goto    END_FP_SW

                movf    FREQ_HI,W            ; VFO to TEMP
                movwf    TP_HI                
                movf    FREQ_LO,W
                movwf    TP_LO                
                movf    FREQ_OST,W
                movwf    TP_OS                

                call    RECALL_VFO            ; Memory to VFO

                call    TEMP2MEM            ; TEMP to Memory
                bsf    SSTAT,UPDATE_FR
                call    LCD_SWAP
                goto    END_FP_SW
NOT_SWAP:
                btfss    FP_TEMP,RATE        ; RATE Switch
                goto    NOT_RATE
                btfss    FP_Switch,RATE        ; Process on button up
                goto    END_FP_SW
                movlw    0x02                ; Invert BIT 1
                xorwf    SSTAT,F                ; Toggle RATE
                call    LCD_RATE
                goto    END_FP_SW
NOT_RATE:
                btfss    FP_TEMP,MODE        ; Mode SW
                goto    NOT_MODE
                btfss    FP_Switch,MODE        ; Process on button up
                goto    END_FP_SW
                bcf    _C                    ; Clear carry bit
                rlf    OPMODE,F            ; Change Mode
                btfss    OPMODE,3            ; if LSB roll around to CW
                goto    MODESW1
                movlw    0x01
                movwf    OPMODE
MODESW1:
                call    SET_OP_MODE
                call    LCD_MODE
                movlw    OPMD
                movwf    EE_ADDR
                movf    OPMODE,W
                movwf    EE_DATA
                call    EE_WRITE
                goto    END_FP_SW
NOT_MODE:
                btfss    FP_TEMP,SELECT
                goto    NOT_SELECT
                call    LCD_CALL
                goto    END_FP_SW
NOT_SELECT:
END_FP_SW:
;
; Meter Routine
                btfsc    PORTB,0
                goto    A2D_DONE            ; Don't do the S Meter while transmitting
                movlw    0x95                ; Start Conversion
                movwf    ADCON0
A2D_LOOP:
                btfsc    ADCON0,GO_DONE
                goto    A2D_LOOP            ; Wait until Conversion is complete
                bcf    _C
                RRF    ADRESH,F            ; Divide by 2
                movlw    0x44                ; Subtract no-sig voltage (2.5 Volts)
                subwf    ADRESH,F
                btfss    _C                    ; if it's less than 0 then make it 0
                clrf    ADRESH
                call    CHECK_KEY
                iorlw    0x00
                btfss    _Z
                goto    A2D_DONE

                movlw    0x14
                call    LCDSDDA                ; Position Cursor

                movlw    0x02
                movwf    L_ONE                ; Single short bar
                movlw    0x03
                movwf    L_TWO                ; Dual short bar
                movlw    0x07
                movwf    CCount                ; CCount = 8
                movlw    0x02
                subwf    ADRESH,W            ; is ADRESH >= 2
                btfss    _C                    ; Yes: Skip
                goto    A2D_SDASH            ; No: Update display
                movf    L_TWO,W
                call    LCDPUTCHAR            ; Print a double bar
                decf    ADRESH,F
A2D_NEXT:
                decfsz    ADRESH,F            ; Dec result and print spaces if 0
                goto    A2D_1
                goto    A2D_SPACE
A2D_1:
                decfsz    ADRESH,F            ; Dec result and print single dash if 0
                goto    A2D_2
                goto    A2D_SDASH
A2D_2:
                movf    L_TWO,W
                call    LCDPUTCHAR
                decfsz    CCount,F
                goto    A2D_SKIP
                goto    A2D_DONE
A2D_SKIP:
                movlw    0x05
                subwf    CCount,W
                btfss    _Z
                goto    A2D_NEXT
                movlw    0x01
                movwf    L_ONE                ; Single long bar
                movlw    0xa0
                movwf    L_TWO                ; Dual long bar
                goto    A2D_NEXT

A2D_SDASH:
                movf    L_ONE,W
                call    LCDPUTCHAR            ; Print a single bar
                decf    CCount,F
                btfsc    _Z
                goto    A2D_DONE
A2D_SPACE:
                movlw    " "
                call    LCDPUTCHAR
                decfsz    CCount,F
                goto    A2D_SPACE

A2D_DONE:
;
; Frequency Counter
                btfss    CNT_STAT,NOT_CTNG
                goto    CNTING                ; If not counting start a count

                clrf    TMR1L                ; Clear Timer1
                clrf    TMR1H                

                bcf    PORTC,4                ; Apply LO to Counter                
                movlw    0x02
                movwf    CNT_STAT            ; Clear not ocunting flag, set LO counting flag
                movlw    .20
                movwf    BCount
                decfsz    BCount,F
                goto    $-1
                movlw    0x3d                ; Timer0 Value
                movwf    TMR0

                bcf    INTCON,T0IF            ; Clear and old interrupt flags
                bsf    INTCON,T0IE            ; Enable the T0 interrupt
                goto    COUNTER_DONE
CNTING:                
                btfss    CNT_STAT,DONE_CTNG    ; Check if count is complete
                goto    COUNTER_DONE
                btfss    CNT_STAT,CTNG_LO    ; Check if counting LO ro BFO
                goto     DISPLAY_FQ

                movf    TMR1L,W                ; Get and save LO count
                movwf    C_FREQL
                movf    TMR1H,W                ; Get and save LO count
                movwf    C_FREQM
                clrf    C_FREQH                
                clrf    TMR1L                ; Clear Timer1 
                clrf    TMR1H                
                bcf    PORTC,3                ; Apply BFO to Counter                
                movlw    0x04
                movwf    CNT_STAT            ; Clear not ocunting flag, set BFO counting flag
                movlw    .20
                movwf    BCount
                decfsz    BCount,F
                goto    $-1
                movlw    0x3d                ; Timer0 Value
                movwf    TMR0

                bcf    INTCON,T0IF            ; Clear and old interrupt flags
                bsf    INTCON,T0IE            ; Enable the T0 interrupt
                goto    COUNTER_DONE
DISPLAY_FQ:
                movlw    0x01
                movwf    CNT_STAT            ; Count Done

                movf    TMR1L,W                ; Anti-jitter routine
                subwf    LAST_B1,W
                btfsc    _Z
                goto    ADD_BFO                ; Same as last count
                movf    TMR1L,W                ; Anti-jitter routine
                subwf    LAST_B2,W
                btfsc    _Z
                goto    ADD_BFO                ; Same as next to last count
                movf    LAST_B1,W
                movwf    LAST_B2
                movf    TMR1L,W
                movwf    LAST_B1                ; Save previous states                
                movf    TMR1L,W                ; Get and save BFO count
                movwf    L0CT1
                movf    TMR1H,W                ; Get and save BFO count
                movwf    LOCT2
ADD_BFO:
                movf    L0CT1,W                ; Get BFO and add to LO count
                btfsc    _Z                    ; No need to add if it's zero
                goto    NOADD
                addwf    C_FREQL,F
                btfsc    _C
                incf    C_FREQM,F
                btfsc    _Z
                incf    C_FREQH,F
NOADD:
                movf    LOCT2,W
                addwf    C_FREQM,F
                btfsc    _C
                incf    C_FREQH,F
                movf    FREQ_STORE,F
                btfsc    _Z
                goto    ANTI_JITTER
                decfsz    FREQ_STORE,F
                goto    ANTI_JITTER
                call    STORE_CUR

ANTI_JITTER:
                movf    DISP_DELAY,F        ; Check of counter=0
                btfsc    _Z
                goto     DISP_FREQ
                decfsz    DISP_DELAY,F
                goto    COUNTER_DONE        ; Don't display the freq until counter reaches 0
                goto    DISP_ANYWAY
DISP_FREQ:
                btfsc    FORCE_D,0
                goto    DISP_ANYWAY
                movf    C_FREQL,W            ; Anti-jitter routine
                subwf    LAST_F1,W
                btfsc    _Z
                goto    COUNTER_DONE        ; Same as last count
                movf    C_FREQL,W            ; Anti-jitter routine
                subwf    LAST_F2,W
                btfsc    _Z
                goto    COUNTER_DONE        ; Same as next to last count
                movf    LAST_F1,W
                movwf    LAST_F2
                movf    C_FREQL,W
                movwf    LAST_F1                ; Save previous states                
DISP_ANYWAY:
                bcf    FORCE_D,0
                call    CHECK_KEY
                iorlw    0x00
                btfss    _Z
                goto    COUNTER_DONE
                call    DISP_C_FREQ
COUNTER_DONE:
;
; High resolution BFO tracking system
                call    BFO_HIRES
                GOTO    LOOP                ; Stay here forever
;
; Interrupt Service Routine
                include        "TAK-ISR.asm"
;
;
; Set LO Frequency
                include     "MCP4922.asm"
;
; EEPROM Read and Write Routines
                include        "TAK-EEPROM.asm"
;
; Memory functions
                include        "TAK-VFOMEM.asm"
;
; Display Messages
                include        "TAK_MSG.asm"
;
; Display Frequency
                include        "TAK_FREQ.asm"
;
; Setup Routines
                include        "TAK_SETUP.asm"
;
; BFO Stabalizer
                include        "TAK_BFO.asm"
;
; TX Meter
                include     "TAK_TXM.asm"

;
; Check For Key Press
CHECK_KEY:
                bsf    STATUS, RP0            ; Switch to bank1
                MOVLW    0x0FF                ; Set PORTD for input
                MOVWF    TRISD
                BCF    STATUS, RP0            ; Select Register page 0

                comf    PORTD,W

                BSF    STATUS, RP0            ; Select Register page 1
                CLRF    TRISD                ; Set PORTD for output
                BCF    STATUS, RP0            ; Select Register page 0
                return
;
; Sets the operating mode CW, USB or LSB
SET_OP_MODE
                bsf    SSTAT,BFO_SEEK
                btfss    OPMODE,2                ; Test for LSB
                goto    MODENOTLSB
; Set BFO to Stored LSB setting (3999.70 to 4002.25 kHz)
                movlw    0x24
                movwf    BFO_FRH
                movlw    BFO_LSB
                movwf    EE_ADDR
                call    EE_READ
                movf    EE_DATA,W
                movwf    BFO_FRL
; current BFO setting
                movlw    BFO_L
                goto    RECALL_BFO
MODENOTLSB:
; Set BFO to Stored USB setting (3997.14 to 3999.69 kHz)
                movlw    0x23
                movwf    BFO_FRH
                movlw    BFO_USB
                movwf    EE_ADDR
                call    EE_READ
                movf    EE_DATA,W
                movwf    BFO_FRL
; current BFO setting
                movlw    BFO_U
RECALL_BFO:
                movwf    EE_ADDR
                call    EE_READ
                movf    EE_DATA,W
                movwf    BFO_STH
                movwf    CCPR1L
                movf    BFO_FRL,W            ; Setup mode only
                movwf    WHEEL                ; Set BFO wheel to current value
                bsf    SSTAT,WHL            ; Clear status flag
                return
;
; LCD Special Character data
CG_DATA:
                movlw    0xa0
                call    LCDPUTCMD
                movlw    0x00
                call    LCDPUTCHAR
                movlw    0x0e
                call    LCDPUTCHAR
                movlw    0x1f
                call    LCDPUTCHAR
                movlw    0x1f
                call    LCDPUTCHAR
                movlw    0x1f
                call    LCDPUTCHAR
                movlw    0x1f
                call    LCDPUTCHAR
                movlw    0x0e
                call    LCDPUTCHAR
                movlw    0x00
                call    LCDPUTCHAR

                movlw    0x00
                call    LCDPUTCHAR
                movlw    0x18
                call    LCDPUTCHAR
                movlw    0x18
                call    LCDPUTCHAR
                movlw    0x18
                call    LCDPUTCHAR
                movlw    0x18
                call    LCDPUTCHAR
                movlw    0x18
                call    LCDPUTCHAR
                movlw    0x18
                call    LCDPUTCHAR
                movlw    0x18
                call    LCDPUTCHAR

                movlw    0x00
                call    LCDPUTCHAR
                movlw    0x00
                call    LCDPUTCHAR
                movlw    0x00
                call    LCDPUTCHAR
                movlw    0x18
                call    LCDPUTCHAR
                movlw    0x18
                call    LCDPUTCHAR
                movlw    0x18
                call    LCDPUTCHAR
                movlw    0x18
                call    LCDPUTCHAR
                movlw    0x18
                call    LCDPUTCHAR

                movlw    0x00
                call    LCDPUTCHAR
                movlw    0x00
                call    LCDPUTCHAR
                movlw    0x00
                call    LCDPUTCHAR
                movlw    0x1b
                call    LCDPUTCHAR
                movlw    0x1b
                call    LCDPUTCHAR
                movlw    0x1b
                call    LCDPUTCHAR
                movlw    0x1b
                call    LCDPUTCHAR
                movlw    0x1b
                call    LCDPUTCHAR
                movlw    0xe0
                call    LCDPUTCMD
                return
                END

TAK_MSG.asm

LCD_STORE:
                call    LCD_START
                movlw    'V'
                call     LCDPUTCHAR
                movlw    0x1a
                call     LCDPUTCHAR
                movlw    'M'
                call     LCDPUTCHAR
                goto    THREE_SPACE
LCD_SWAP:
                call    LCD_START
                movlw    'S'
                call     LCDPUTCHAR
                movlw    'w'
                call     LCDPUTCHAR
                movlw    'a'
                call     LCDPUTCHAR
                movlw    'p'
                call     LCDPUTCHAR
                goto    TWO_SPACE
LCD_VFO:
                call    LCD_START
                movlw    'V'
                call     LCDPUTCHAR
                movlw    'F'
                call     LCDPUTCHAR
                movlw    'O'
                call     LCDPUTCHAR
                movlw    ' '
                call     LCDPUTCHAR
                btfsc    PORTC,1
                goto      LCDV1
                movlw    'B'
                call     LCDPUTCHAR
                goto    ONE_SPACE
LCDV1:
                movlw    'A'
                call     LCDPUTCHAR
                goto    ONE_SPACE
LCD_RATE:
                call    LCD_START
                btfsc    SSTAT,RATE
                goto      LCDR1
                movlw    'S'
                call     LCDPUTCHAR
                movlw    'l'
                call     LCDPUTCHAR
                movlw    'o'
                call     LCDPUTCHAR
                movlw    'w'
                call     LCDPUTCHAR
                goto    TWO_SPACE
LCDR1:
                movlw    'F'
                call     LCDPUTCHAR
                movlw    'a'
                call     LCDPUTCHAR
                movlw    's'
                call     LCDPUTCHAR
                movlw    't'
                call     LCDPUTCHAR
                goto    TWO_SPACE
LCD_CALL:
                call    LCD_START
                movlw    'W'
                call     LCDPUTCHAR
                movlw    'A'
                call     LCDPUTCHAR
                movlw    '2'
                call     LCDPUTCHAR
                movlw    'E'
                call     LCDPUTCHAR
                movlw    'U'
                call     LCDPUTCHAR
                movlw    'J'
                call     LCDPUTCHAR
                goto    LCDDONE

LCD_MODE:
                call    LCD_START
                movlw    0x08
                call    LCDSDDA
                btfss    PORTB,0
                goto    LCDM0
                movlw    'T'
                call     LCDPUTCHAR
                movlw    'X'
                call     LCDPUTCHAR
                movlw    ' '
                call     LCDPUTCHAR
                return
LCDM0:
                btfss    OPMODE,0
                goto      LCDM1
                movlw    'C'
                call     LCDPUTCHAR
                movlw    'W'
                call     LCDPUTCHAR
                movlw    ' '
                call     LCDPUTCHAR
                return
LCDM1:
                btfss    OPMODE,1
                goto      LCDM2
                movlw    'U'
                call     LCDPUTCHAR
                movlw    'S'
                call     LCDPUTCHAR
                movlw    'B'
                call     LCDPUTCHAR
                return
LCDM2:
                movlw    'L'
                call     LCDPUTCHAR
                movlw    'S'
                call     LCDPUTCHAR
                movlw    'B'
                call     LCDPUTCHAR
                return
THREE_SPACE:
                movlw    ' '
                call     LCDPUTCHAR
TWO_SPACE:
                movlw    ' '
                call     LCDPUTCHAR
ONE_SPACE:
                movlw    ' '
                call     LCDPUTCHAR
LCDDONE:
                movlw    .8
                movwf    DISP_DELAY
                return
LCD_START:
                movlw    LCD_HOME            ; Position cursor leftmost on first line
                call    LCDPUTCMD
                bcf        INTCON,T0IE            ; Dump Current Count
                movlw    0x01
                movwf    CNT_STAT            ; Count Done
                return
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License