The PIC18F57Q43 is one of Microchip's PIC18 Q-series parts: 128 KB of flash, 8 KB of RAM and 1 KB of data EEPROM, in a 48-pin package. Like the PIC16 parts, it has no SWD port and no factory bootloader, and it is programmed over ICSP: a clock pin, a data pin and MCLR.
A BenchPod programs it with the same pin programmer and the same wiring as a PIC16. The protocol basics are shared, and Programming the PIC16F18446 over ICSP covers them: low-voltage entry with the MCHP key, the 8-bit command set, the 24-bit payloads and the read timing. This article covers what PIC18 Q does differently, and what we measured. It is part of a series, one per chip we have run on real hardware: the overview of how the BenchPod flashes microcontrollers lists them all.
What is the same
- Entry. MCLR low, then the 32-bit key
MCHP(0x4D434850), most significant bit first, with no high voltage, as long as the LVP configuration bit is set. - Commands. 8 bits, most significant bit first. Load PC (
0x80), Read Data with increment (0xFE) and Bulk Erase (0x18) keep their codes. - Payloads. 24 bits: a 0 start bit, 22 data bits and a 0 stop bit, the value shifted left by one.
- Read timing. The chip drives each bit after the rising clock edge and holds it until the next one; the pod samples it while the clock is high.
- The job. The pod reads the ID and checks it before it erases anything, erases, writes, reads every location back, and releases MCLR so the program runs.
What is different on PIC18 Q
A longer wait after the key. The pod waits 1.2 ms after the key before the first command (the chip asks for 1 ms; a PIC16F18xxx needs 250 µs).
Byte addressing. On a PIC16 the PC counts 14-bit words. On PIC18 Q it counts bytes, and every memory has its own range in a 22-bit address space. Flash words are 16 bits, so Read Data with increment moves the PC on by 2 in flash, and by 1 in the byte-wide configuration and EEPROM ranges. These are the addresses XC8 puts in a hex file, so the image needs no translation.
| Address | What it is |
|---|---|
0x000000 to 0x01FFFF | Program flash, 128 KB in 16-bit words |
0x200000 | User ID, 32 bytes |
0x300000 to 0x300009 | CONFIG1 to CONFIG10, one byte each |
0x380000 to 0x3803FF | Data EEPROM, 1 KB |
0x3FFFFC, 0x3FFFFE | Revision ID, device ID |
The PIC18F57Q43 reads device ID `0x74C0`; the revision on our chip was 0xA080.
One command per word. A PIC16F18xxx fills a row with Load Data commands and then programs the whole row with Begin Programming. PIC18 Q has neither. Every location is written by its own Program Data command, 0xE0 with a 24-bit payload, and the chip times the write itself and then moves the PC on:
- A flash word takes about 50 µs on the Q43, and the PC moves on by 2. The pod sets the PC once per 256-byte block and then streams Program Data commands.
- A configuration byte or an EEPROM byte uses the same command with the byte in the low bits. Each takes about 11 ms, and the PC moves on by 1.
A full 128 KB image is therefore 65536 Program Data commands.
Bulk Erase takes a payload. On the PIC16F18446 the PC selects what a bulk erase covers. On the Q43 the command carries a payload whose low four bits pick the regions: data EEPROM, flash, user ID and configuration bytes. The pod sends 0x0F, all four, which also clears code protection.
A bulk erase needs the supply above about 2.85 V on this chip. Below that the chip can skip it and keep its old contents, so the SDK refuses a chip erase at a lower voltage.
Wiring a PIC18F57Q43 Curiosity Nano
The wiring is the same as for the PIC16F18446 Curiosity Nano: with the Nano's USB unplugged, its on-board debugger is off and the target's ICSP lines are on the DBG pins.
| Pod (J1) | Curiosity Nano | Signal |
|---|---|---|
| LA3 | DBG0 | ICSPDAT |
| LA4 | DBG1 | ICSPCLK |
| pin 22, reset | DBG3 | MCLR |
| GND | GND | ground |
| pin 17, +3V3 | VTG | target supply |
The board's LED0 is on RF3.
Bench results
We ran the PIC18F57Q43 Curiosity Nano at 3.3 V with the wiring above:
- The SDK identified the chip from its ID on the first try, without a device name: device ID `0x74C0`, revision
0xA080. - A blink program, 256 bytes of flash and 2 configuration bytes, was written and verified in 1.2 s. The chip then ran it and the LED blinked.
- A full test image, 128 KB of random flash data plus 64 bytes of data EEPROM, was written and verified in 93 s: 91.4 s for the flash, 1.3 s for the EEPROM.
Things to know
Erased configuration bytes do not make a running program. As on the PIC16, the erased value is all ones, and on the Q43 that selects an external oscillator (CONFIG1, FEXTOSC and RSTOSC) and turns the watchdog on (CONFIG5, WDTE). Put the configuration bytes in the image: XC8 does that from the #pragma config lines. Our blink program wrote CONFIG1 0xEC (external oscillator off, HFINTOSC at 1 MHz) and CONFIG5 0x9F (watchdog off).
Erased CONFIG4 turns on the extended instruction set. CONFIG4 holds XINST, which is 1 when erased. With it set, the chip uses the extended instruction set, which changes how access-bank addresses below 0x60 are addressed. Code built for the standard instruction set can then read and write the wrong locations. Set XINST off in the image unless the code is built for the extended set; an image without configuration bytes leaves it on.
CONFIG4 also holds LVP. Clearing it turns off low-voltage entry, and with it every programmer that has no high voltage for MCLR. Our blink left CONFIG4 at its erased value.
Flash writes are per word. Writing a full 128 KB image is much slower than on a PIC16 with row writes, because every 16-bit word is its own command and its own wait. Write only what the image contains: the SDK sends only the regions in the file.
Using it
From Python, with the pytest package:
from embeddedci.benchpod import BenchPod
with BenchPod("192.168.1.50", la_voltage=3.3) as bp:
# Only enter programming mode and read the ID: a wiring check, nothing is written.
print(bp.flash(target="pic", clk=4, data=3, dry_run=True).stdout)
r = bp.flash(target="pic", device="PIC18F57Q43", clk=4, data=3, file="blink.hex")
assert r.ok, r.stderrWithout device, the SDK tries the PIC entry styles and identifies the chip from its ID. A .hex that carries configuration bytes, a user ID or data EEPROM gets all of them written, each as its own region. From an AI agent, the MCP server's flash tool takes the same arguments: flash(target="pic", device="PIC18F57Q43", clk=4, data=3, file="blink.hex").
The CLI's benchpod flash --target pic does not handle the PIC16F18xxx and PIC18 Q chips yet; use the SDK or the MCP server for them.
Underneath, each region is one JSON command after the image is staged in the pod's memory:
{"cmd":"prog_flash","op":"start","proto":"pic","clk":4,"data":3,"mem":"flash","addr":0,"len":256,
"page":256,"erase":"chip","expect_id":"c074","cmd_set":"8bit","pc":"byte","cp_bit":0,"cp_addr":3145737,"run":true}cmd_set and pc select the 8-bit command set with byte addressing (firmware before 4.0.6: flags 3), cp_bit is the code-protect bit, and cp_addr (0x300009) is the configuration byte that holds the code-protect bit. The full reference is in the API docs.
PIC programming works on real chips from firmware 4.0.5 and SDK 4.0.5, with the pin-programmer image installed with benchpod install-blobs. The same pic target covers the PIC18 Q10, Q40, Q43, Q83 and Q84 families. Every chip and method we have verified on real hardware is in How the BenchPod flashes microcontrollers.