Microcontroller Programming – Can You Program a Microcontroller Without a Computer?


Let's say you had a rather simple and small microcontroller and had no interfacing, no computer, no debugger, compiler, or assembler. Could you write your code in assembly, convert it (manually) to machine code, and then apply power to the appropriate pins using a voltage source?

I understand you would need appropriate I/O and memory to really do anything, but if you were so inclined and had the time, could you do this? I guess, historically, how was this done when there was no computer/compiler/assembler to begin with? Feel free to link me to an outside resource. Thanks! 🙂

Best Answer

Could you write your code in assembly, convert it (manually) to machine code,

Code can be written "out of your head" in binary, if you wish.
Long (long long) ago this is how I started using (then) microprocessors.
I and friends would write code in assembly language, compile it manually to machine code (something you can do "by inspection" after some practice) then enter it into the processor by various means. On one system we built we would set up the address on binary (on off) switches or use an auto increment feature of the processor, enter 8 data bits on binary switches and then press a "clock" switch to enter the data to memory.

The equivalent functionality could be achieved with even fewer switches on a modern microcontroller using serial SPI programming - see below.

... and then apply power to the appropriate pins using a voltage source?

But it would be incredibly slow to do!
Many modern microcontrollers allow use of an "SPI" interface for programming.
This typically consists of input and output data lines and a "clock" line, and usually a reset line.

Many processors allow SPI clock and data to be "static" which means there is no limit on how long you can take to set up the data between bits. You could program such a processor using a data line and a clock line which were driven by manually operated switches. The clock line needs to be "bounce free" - you need to be able to set it high or low in a single transition per operation - so a minimum interface may need to include a Schmitt triggered gate. You may "get away with" just an RC delay and a push button switch, but a Schmitt triggered input is safer. The data line does not need to be bounce free as its state is only read at the clock edge.

Some interfaces are interactive - data is output by the processor during programming (eg data out = MISO = Master In Serial Out on AVR processors). To read this you'd need to add eg an LED and a resistor (and just maybe a buffer or transistor if the drive capability was REALLY low).


From semi-fading memory (almost 40 years!)

LDI A, $7F ...... 86 7F ...... 1000 0110 0111 1111
STA, $1234...... B7 12 34 ... 1011 0111 0001 0010 0011 0100
LDI X, $2734... CE 27 34 ... 1100 1110 0010 0111 0011 0100