Programme uC in situ - Page 1
Forum section: electronics / general

author: PerranOak
author_rank: Frequent Contributor
timestamp: June 12, 2025, 12:54:59 pm
content: Is thee an easy method to programme a uC in its circuit without having to take it out.I have projects where I have put the uC (I usually use PICs) in a socket so programming it is easy as I simply take it out.However, if I wanted to solder it in place, is there a "normal" way to accomplish this given that the enhanced voltages needed to programme may damage the rest of the circuit?Cheers.

author: eutectique
author_rank: Frequent Contributor
timestamp: June 12, 2025, 01:20:02 pm
content: Some microcontrollers, like SAMV70, allow programming via USB or serial line. Erase all flash with a pin, and it will wait to be programmed automagically. The boot protocol is explained in the datasheet.Do you have some specific part in mind, or just a general question of yes/no ?

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: June 12, 2025, 01:26:56 pm
content: All modern MCUs can be programmed in-circuit, either via dedicated pins or USB

author: brucehoult
author_rank: Super Contributor
timestamp: June 12, 2025, 01:39:20 pm
content: Quote from: PerranOak on June 12, 2025, 12:54:59 pmIt depends on the uC. I've reprogrammed ATTiny85 chips in situ in commercial products, with a SOIC8 clip."Enhanced voltages" are not usually needed with modern chips. Many can write to their own flash in the normal course of program execution (if you don't disable it) so you can use part of the flash for config data or as a disk drive / database etc. Or you can have a small "bootloader" that loads new data from UART or USB or whatever and writes it to flash -- that's how AVR Arduinos have always worked for 15 years.Many chips use basically an SPI protocol to program them, with for example an extra connection to hold the chip in RESET while programming it. Chips with a small number of pins may have a "1 wire" programming/debug protocol (so GND plus Vcc plus 1 wire). Arm have a proprietary 1-wire protocol for some of their stuff, WCH for example has one for their smaller CH32V003 device.It's usually pretty easy as long as the existing software in the chip doesn't configure the reprogramming pin (or maybe RESET) as an output immediately after reset. You often either need a short delay so the programmer can get in, or else if that pin is an input it's no problem at all -- the programmer just has to overpower whatever else in the circuit is trying to drive that input. and usually you'd put a small resistor to that input to make that easy.

author: fchk
author_rank: Frequent Contributor
timestamp: June 12, 2025, 02:13:17 pm
content: Quote from: PerranOak on June 12, 2025, 12:54:59 pmModern PICs support low voltage programming and don't need the usual 9V or 13.5V any more. There is no need to use ancient types like 16F74 or 16F288. PIC24, dsPIC33 and PIC32 always support LVP.You need the standard 5-pin header: MCLR-VCC-GND-PGD-PGC. 10k between VCC and MCLR. Thats it.The "burners" you know come from the times where PICs still had EPROM based program memory. They are obsolete now. A PICKIT5 can program almost every current microcontrller from Microchip: AVRs, PICs (8, 16, 32 bit), ARM (ATSAM, PIC32C). The only blind spot are the 8051 series they still sell - both the old Atmel controllers and the SST ones.

author: Ian.M
author_rank: Super Contributor
timestamp: June 12, 2025, 02:25:34 pm
content: The need to program devices in a ZIF socket then transplant them into a socket on your board went away with parallel programming, circa Y2K. Even old PICs that needed 13V programming voltage (Vpp) only needed that on one pin, /MCLR the reset pin, which was rarely used for anything else, so unless an external reset shared with other devices was used it was little trouble to isolate it from external circuits. If you did need to, an open drain/collector buffer with adequate output voltage rating above its supply feeding the PIC and ICSP programming header /MCLR pins + a 10K pullup from /MCLR to Vdd was an easy fix.Isolating programming clock and serial data signals (PGC/ICSPCLK and PGD/ICSPDAT) was also usually fairly easy - if you used them as inputs, a series resistor of a couple of K between the output driving them and the PIC pin (+ ICSP header) was sufficient.A bigger problem was excessively Muntzed designs (popular in the Australian magazine 'Silicon Chip') that used every single pin the PIC had with /MCLR disabled so it could be used as an input. If PGC and/or PGD were used as outputs, defaulted high, and the programmer was incapable of powering the target board, the target PIC would become virtually unprogrammable, as program mode entry required PGC and PGD to be low at the rising edge of the programming voltage, and development programmers had insufficient drive to pull down a PIC output that was set high.Another issue was PICs rated for low supply voltage operation that needed over 4.5V Vdd to bulk erase (or even program). If you had 3.3V devices sharing the same Vdd as the PIC, attempting to reprogram in-circuit would either fail (if using target power) or blow the **** out of your board if the programmer was supplying power. In one case, an engineer had a target board that ran direct from a single LiPO on their bench for a debug session, went to lunch without physically disconnecting the target, and came back to find their bench on fire as MPLAB had glitched and enabled target power on the PICkit 3, overcharging the LiPO till it blew. Fortunately the fire wasextinguished before the building went up, but their desk, PICkit 3, target board, and IIRC PC and most of the desk contents were a write-off, and they and their colleagues got to stand around in the car park for half the afternoon!Microchip programmer/debuggers require target Vdd to be connected to set the logic high reference level for the output buffers, but if you are using a self-powered target, a Schottky diode in the programming cable in series with Vdd_target to block power from the programmer can prevent a lot of drama!

author: Geoff-AU
author_rank: Frequent Contributor
timestamp: June 12, 2025, 11:54:18 pm
content: I've been using In-System-Programming (ISP) on (ex)Atmel AVRs for >20 years. AVRISP or similar, with a 6-pin SPI header for the programmer. Absolutely no need to remove ICs for programming.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: June 13, 2025, 01:09:08 am
content: Quote from: PerranOak on June 12, 2025, 12:54:59 pmDo you have some type numbers of PIC's you have used (or want to use).ISP (In Circuit Programming) is very common for a long time, as others have already posted here. For microchip, the "Pickit 3" is (or was?) a popular programmer. I find it quite expensive though. I'm more used like paying between EUR3 and EUR 10 for a hobby level programmer. The first chip I ever programmed was an PIC16F84, and I did that with a breadboard and a few wires stuck into the LPT port.

author: brucehoult
author_rank: Super Contributor
timestamp: June 13, 2025, 01:18:30 am
content: Quote from: Doctorandus_P on June 13, 2025, 01:09:08 amAll the MCUs I use can be programmed using a specially programmed arduino (which includes e.g. the $1.50 nanoCH32V003, though in that case you need a generic USB/UART dongle to talk to *it*) or $4 Pi Pico. And all the programming software is on github.

author: PerranOak
author_rank: Frequent Contributor
timestamp: June 13, 2025, 01:46:09 pm
content: Great, thanks all.There's possibly, the problem. I like using old, simple PICs, e.g. 12F683, 16F866 and my fav 16F1829.

author: JPortici
author_rank: Super Contributor
timestamp: June 13, 2025, 02:14:56 pm
content: I hope you are aware that with those pic are being programmed with the ICSP interfacewhich is an acronym for "In Circuit Serial Programming"You either dedicate the programming pins solely for programming (better) or you design the circuit correctly to permit the programmer to connect to the PIC even if it has additional circuitry on the pins.Find the user manual for the programmer, the instructions are there

author: PerranOak
author_rank: Frequent Contributor
timestamp: June 13, 2025, 02:31:41 pm
content: Yes, exactly. To "design the circuitry correctly" is the main thrust of my question.Is that easy? Is it a standard technique (switches, etc.)? Or is it just something designers have to figure themselves, from scratch, each time?

author: JPortici
author_rank: Super Contributor
timestamp: June 13, 2025, 02:45:27 pm
content: Quote from: JPortici on June 13, 2025, 02:14:56 pm

author: ralphrmartin
author_rank: Frequent Contributor
timestamp: June 13, 2025, 03:34:34 pm
content: Another alternative is to use something like an ESP32 with WiFi, and then use OTA (over the air) programming.

author: fchk
author_rank: Frequent Contributor
timestamp: June 14, 2025, 03:58:32 am
content: Quote from: PerranOak on June 13, 2025, 02:31:41 pmJust look for devboard like this one:https://www.microchip.com/en-us/development-tool/DM164137Full schematics available. They show you how to do it.

author: PerranOak
author_rank: Frequent Contributor
timestamp: June 14, 2025, 11:20:11 am
content: Cheers both.