Skip to content

Latest commit

 

History

History
198 lines (161 loc) · 13.8 KB

README.org

File metadata and controls

198 lines (161 loc) · 13.8 KB

MCU firmware for PCI16F1827

NOTE: this firmware has been developed on board v1.2 therefore if you are using an early version and you notice something wrong don’t esitate to open an issue or a pull request. thank you.

Changes from N7DDC

  • 100% free software. This was the main reason to start the project since I would a fully open source and future proof platform and the N7DCC’s mcu firmware is only available in binary form.
  • use a by-directional ASYNC protocol between MCU and FPGA that can send ANY command at ANY time (probably we can implement a remote update of the MCU)
  • each radio’s status is displayed on the screen; for example when you attach the power you see the STANBY screen or when you change the power amplifier status you get a message with the actual value.
  • every configuration parameter is stored on the FPGA eeprom and not half on the MCU and half on the FPGA.
  • full status on the bootloader screen
  • amplifier values can be modified from the programmer (no mic needed)
  • code comments everywhere
  • free available PIC compiler (maybe move to SDCC)

Notes

  • when you flash this firmware over N7DDC you need to re-calibrate the PD85004s resistor since the RA2 voltage is different.

Functionalities

functiondescriptionavailability
radio powerthe MCU manage the ON/OFF of the radio. You can power on/off with power button or MIC FST buttonany time
displaymanage the SSD1306 display printing the radio’s status (standby, bootloader, ready, PTT, ecc.) and the parametersany time
fpgaan ASYNC UART channel between MCU and FPGA permits to exchange status and parameters (like, IP, version, slot)any time
1W power amplifiermanage the line that enable/disable the 1W power amplifier; configured by FPGA or a long press of MIC DOWN button (flip)any time except transmitting
audio amplifiermanage the line that enable/disable the audio amplifier; configured by FPGA or a long press of MIC UP button (flip)any time except transmitting
auto power onyou can power the radio the the power source is enable therefore without touching any button; good for remote operationonly at bootloader
change slotpermits to change the slot to boot with a short press of MIC DOWN or MIC UPonly at bootloader

All configurations can be seen on the screen at bootloader and changed with the MIC or the programmer.

PIN connections

PINdescription
RA0not connected
RA1not connected
RA21W Power Amplifier 1 = ON; 0 = OFF (enabled only during PTT)
RA3MIC FST long press power on the radio (like power on button)
RA4not connected
RA5MCLR used for programming reset
RA6Audio Amplifier 1 = OFF; 0 = ON
RA7MIC UP (pull-up) –> NO Interrupt on Change available
RB0power on button (pull-up) pressed when 0
RB1i2c SDA display (pull-up)
RB2TPS62140 enable line (board 5V) 1 = ON; 0 = OFF
RB3MIC DOWN (pull-up)
RB4i2c SCL display (pull-up)
RB5not used - connected to FPGA J22
RB6UART TX to FPGA L22 and CLK programmer (pull-up only when radio board is on)
RB7UART RX to FPGA L21 and DAT programmer (pull-up only when radio board is on)

MCU-FPGA protocol

The protocol uses an ASYNC UART (pins RB6 and RB7) with the following parameters: 19200-8N1. The message exchange is half-duplex. The first byte sent is always a command. The next bytes are optional and depends on the command. An “FPGA ERROR” is shown in the display if the STAGE is not received. Each command that require an ACK must acknowledged before sending another command; in an another way, no multiple commands requiring ACK could be sent at the same time.

command byte (8 bits)

X X X X X X X X
| | | | | | | |
| | | | + + + + --> 4 bits for optional parameters
| | | |
+ + + +--> 4 bits that indicate the command
HEXcommanddirectionstagerequire ACKnext bytesparametersdescription
0x00reservednonereserved command
0x1XACKbothanynono0x? is the command to acknowledgeacknowledge command
0x2XSTAGEfpga to MCUanynono0x0 = reservedfpga inform the MCU in which state it is
0x1 = booting
0x2 = bootloader
0x3 = radio
0x4 = PTT
0x5 = CRC error
0x3XVERSIONbothbootloader/radionoyes, 8 bytes0x0 = reservedsend the software version
0x1 = MCU (not implemented)
0x2 = bootloader
0x3 = radio
0x40IPfpga to MCUbootloader/radionoyes, 16 bytesnosend the IP address to MCU
0x5XSTATUSbothbootloadernonosee belowsend the status (see below)
0x6XPOWER ONbothbootloadernono0x0 = request datamcu power on the radio just after the power connector is connected
0x1 = enabled
0x2 = disabled
0x70SWRfpga to MCUPTTnoyes, 2 bytesnosend the SWR value to MCU to display it during PTT

STATUS command

the optional parameters of the STATUS command have the following values

bitvaluedescription
3:200request the status
01slot1
10slot2
11slot3
101W power amplifier disabled
11W power amplifier enabled
00audio amplifier disabled
1audio amplifier enabled

How to build and flash the firmware

Requirements

To build the software you only need two software:

  • Microchip MPLAB XC8 available for Windows, macOS and Linux
  • make (Posix compliant should be enough like, GNU make or BSD make)

Build

If you have installed correctly the software above and xc8 is available in you shell you only need to run one command:

make

At the end, you can see the “Memory Summary” and the firmware will be available at dist/default/production/mcu.production.hex

You can also use MPLAB X IDE if you would like to use an integrated environment to build and flash the firmware.

Flash

There are many in-circuit programmer in the market that you can select to flash the .hex the only requirements is to use ones that support low voltage programming. This is very important otherwise you can damage the FPGA (see the 4.5V zener in the layout). I used the following:

Just pay attention on which device powers the MCU and if something fails double check the wire connections.

License

Copyright (C) 2020 Davide Gerhard IV3CVE

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.