From 5d468cd86a54dfc7a957ff9aaa9fe266125c0ebe Mon Sep 17 00:00:00 2001 From: Ryan Malloy Date: Wed, 28 Jan 2026 18:05:55 -0700 Subject: [PATCH] Add ICSP programming guide Documents the 6-pin ICSP header for bootloader forcing (jumper method) and direct PICkit programming. Includes pinout table, PICkit connection mapping, MPLAB X/IPECMD instructions, and notes on the PIC18F46J11 vs PIC18F45K22 discrepancy between schematics and manual. --- astro.config.mjs | 1 + src/content/docs/guides/icsp-programming.md | 187 ++++++++++++++++++++ 2 files changed, 188 insertions(+) create mode 100644 src/content/docs/guides/icsp-programming.md diff --git a/astro.config.mjs b/astro.config.mjs index e4f16cc..2df8a08 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -40,6 +40,7 @@ export default defineConfig({ { label: 'Beacon Operation', slug: 'guides/beacon-operation' }, { label: 'Repeater & Satellite', slug: 'guides/repeater-satellite' }, { label: 'Firmware Upgrade', slug: 'guides/firmware-upgrade' }, + { label: 'ICSP Programming', slug: 'guides/icsp-programming' }, ], }, { diff --git a/src/content/docs/guides/icsp-programming.md b/src/content/docs/guides/icsp-programming.md new file mode 100644 index 0000000..ca20a90 --- /dev/null +++ b/src/content/docs/guides/icsp-programming.md @@ -0,0 +1,187 @@ +--- +title: ICSP Programming +description: Programming the RS-UV3A microcontroller via the ICSP header +--- + +The RS-UV3A includes a 6-pin In-Circuit Serial Programming (ICSP) header for programming the PIC microcontroller. This header serves two purposes: + +1. **Bootloader forcing** — Jumper pins to force bootloader mode on startup (for firmware updates when the board is unresponsive) +2. **Direct ICSP programming** — Connect a PICkit or similar programmer to flash firmware directly + +For routine firmware updates using the bootloader, see the [Firmware Upgrade](/guides/firmware-upgrade/) guide. + +## ICSP Header Location + +The ICSP header is a 6-pin (3×2) header located near the PIC microcontroller (U2) on the left side of the board. The pins are **staggered** — offset from the standard 0.1" grid — to allow a programming clip or individual test probes to make contact without soldering a header. + +:::tip[Staggered Pins] +The staggered design means you can press a standard 2×3 pin header into the holes and it will friction-fit for programming. No soldering required. +::: + +## ICSP Header Pinout + +Viewed from the top of the board: + +``` + 1 2 + ● ● + 3 4 + ● ● + 5 6 + ● ● +``` + +| Pin | Signal | Description | +|:---:|--------|-------------| +| 1 | Boot Select A | Jumper to pin 2 forces USB/JP1 bootloader on startup | +| 2 | VDD (+3.3V) | PIC supply voltage | +| 3 | PGD | Programming data (PIC RB7, pin 17) | +| 4 | PGC | Programming clock (PIC RB6, pin 16) | +| 5 | GND | Ground | +| 6 | Boot Select B | Jumper to pin 5 forces DB-9 bootloader on startup | + +## Method 1: Bootloader Forcing (Jumper) + +If your RS-UV3A is unresponsive (bad firmware upload, corrupted flash), you can force it into bootloader mode on power-up: + +### USB / JP1 Serial Upload + +1. Power off the RS-UV3A +2. Place a jumper across **pins 1–2** +3. Power on — the board enters bootloader mode on USB/JP1 +4. Upload firmware using mikroBootloader at 115200 baud +5. Power off and **remove the jumper** +6. Power on — normal operation resumes + +### DB-9 Serial Upload + +1. Power off the RS-UV3A +2. Place a jumper across **pins 5–6** (or 4–5, verify against your board revision) +3. Power on — the board enters bootloader mode on DB-9 +4. Upload firmware using mikroBootloader at 115200 baud +5. Power off and **remove the jumper** +6. Power on — normal operation resumes + +:::caution[Remove the Jumper] +Always remove the bootloader jumper after programming. If left in place, the RS-UV3A will enter bootloader mode every time it powers on instead of running normally. +::: + +For the full bootloader upload process, see [Firmware Upgrade](/guides/firmware-upgrade/). + +## Method 2: Direct ICSP Programming (PICkit) + +For advanced users who need to flash the PIC microcontroller directly — for example, to restore a corrupted bootloader or flash custom firmware. + +### What You Need + +| Item | Notes | +|------|-------| +| **PICkit 3, 4, or 5** | Microchip in-circuit programmer/debugger | +| **MPLAB X IDE** | Free download from [microchip.com](https://www.microchip.com/mplab/mplab-x-ide) | +| **Firmware .HEX file** | From HobbyPCB or compiled from source | +| **2×3 pin header** (optional) | Press-fit into staggered ICSP holes | + +### PICkit Connection + +The PICkit programmer needs five signals. Connect to the ICSP header as follows: + +| PICkit Pin | Signal | ICSP Header | +|:----------:|--------|:-----------:| +| 1 | MCLR/VPP | See note below | +| 2 | VDD | Pin 2 | +| 3 | VSS (GND) | Pin 5 | +| 4 | PGD (ICSPDAT) | Pin 3 | +| 5 | PGC (ICSPCLK) | Pin 4 | + +:::warning[MCLR Connection] +The ICSP header may not break out the ~MCLR signal (PIC pin 18) directly. Check your board revision's schematic on the [Schematics](/reference/schematics/) page. If MCLR is not on the header, you may need to connect the PICkit's MCLR line directly to PIC pin 18 or the ~MCLR trace on the board. +::: + +### MPLAB X Configuration + +1. Open MPLAB X IDE +2. Create a standalone project or open the firmware project +3. Select the target device: **PIC18F46J11** +4. Select the programmer tool: **PICkit 3** (or 4/5) +5. Under Project Properties → PICkit: + - Set **Power** to *not* supply voltage from PICkit (the RS-UV3A has its own 3.3V regulator) + - Set **Voltage Level** to **3.3V** if powering from PICkit + +:::danger[Voltage Warning] +The PIC18F46J11 is a **3.3V device**. Never apply 5V to the programming pins. If using the PICkit to supply power, ensure it is set to 3.3V output. Applying 5V will damage the microcontroller. +::: + +### Programming Steps + +1. Connect the PICkit to the ICSP header +2. Power the RS-UV3A (or enable PICkit power at 3.3V) +3. In MPLAB X, click **Make and Program Device** (or use `ipecmd` for command-line) +4. Verify the programming completed successfully +5. Disconnect the PICkit +6. Power cycle the RS-UV3A + +### Command-Line Programming (IPECMD) + +For automated or headless programming using Microchip's IPECMD: + +```bash +ipecmd -P18F46J11 -TPPK4 -M -F"RS_UV3_FIRMWARE.HEX" -OL +``` + +| Flag | Meaning | +|------|---------| +| `-P18F46J11` | Target PIC device | +| `-TPPK4` | Tool: PICkit 4 (use `-TPPK3` for PICkit 3) | +| `-M` | Program device | +| `-F"..."` | Firmware .HEX file path | +| `-OL` | Release from reset after programming | + +## Microcontroller Details + +From the schematics, the RS-UV3A uses: + +| Parameter | Value | +|-----------|-------| +| **MCU** | PIC18F46J11-I/PT (U2) | +| **Package** | TQFP-44 | +| **Flash** | 64 KB | +| **VDD** | 3.3V | +| **PGD** | RB7 (pin 17) | +| **PGC** | RB6 (pin 16) | +| **MCLR** | Pin 18 | + +:::note[PIC18F45K22 Reference in Manual] +The HobbyPCB manual references the PIC18F45K22 when describing the mikroBootloader setup. However, the schematics for Rev A and Rev C both show a **PIC18F46J11-I/PT**. The bootloader selection in mikroBootloader may use the PIC18 family setting generically. When using MPLAB X or IPECMD for direct programming, select **PIC18F46J11**. +::: + +## When to Use Each Method + +| Scenario | Method | +|----------|--------| +| Routine firmware update | [Bootloader (BL command)](/guides/firmware-upgrade/) | +| Board won't respond to commands | Bootloader forcing (ICSP jumper) | +| Corrupted bootloader | Direct ICSP (PICkit) | +| Custom firmware development | Direct ICSP (PICkit) | +| Factory programming | Direct ICSP (PICkit) | + +## Troubleshooting + +### PICkit Can't Connect + +- Verify PGD, PGC, VDD, GND connections +- Check that MCLR is accessible to the PICkit +- Ensure the RS-UV3A is powered at 3.3V +- Try reducing PICkit programming speed in MPLAB X + +### Programming Succeeds but Board Won't Boot + +- Verify the correct .HEX file was used +- Check that the bootloader region was preserved (if applicable) +- Try the bootloader jumper method as a fallback +- Ensure configuration bits are correct for the PIC18F46J11 + +### Staggered Pins Won't Hold Contact + +- Use a press-fit 2×3 header and apply light finger pressure +- Solder a header if you program frequently +- Use a spring-loaded pogo pin adapter (e.g., Tag-Connect TC2030)