Summary of Micro-controller Programming on a Bread Board
### Summary Pugs and his junior Vinay successfully programmed an ATmega16 microcontroller using only a laptop, avoiding external hardware programmers. They utilized the avrdude software to flash a "blink led" program via USB-to-Serial conversion. To resolve voltage level mismatches between the serial port (+/-12V) and the microcontroller (0/+5V), they employed a MAX232 IC for translation. The setup included an LED on Port B0 and a reset circuit with a pull-up resistor and jumper J1 to manage programming versus execution modes.
Parts used in the Micro-controller Programming Project:
- ATmega16 microcontroller
- MAX232 IC
- Laptop with USB port
- USB to Serial converter
- LED
- Resistor
- Pull-up resistor
- Jumper J1
In playing around with DIY electronics, Pugs has developed enough confidence to share his knowledge with his juniors. So, in one such occasion, he decided to give a try to program a micro-controller, as part of the electronics hobby club. There have been many hobbyist micro-controllers, like 8051, PIC, AVR, … and an equivalent or more varieties of hardware programmers to program them. However, Pugs’ goal was different – how can a DIY electronics learner, one as he is, do program a micro-controller in the simplest possible way with no unknown pieces of hardware, meaning no external hardware programmers. First fundamental question was if that was even possible.
“Hey Pugs, seems like it can be achieved with AVR controllers – they have a simple serial programming mechanism using their MOSI, MISO, SCK lines”, exclaimed his junior Vinay, while going through the AVR ATmega16 datasheet pg 273-277.
“Yes, seems possible, at least on the AVR side – we may just have to figure out, how to control these lines from a laptop”, asserted Pugs, reviewing the same.
“Can’t we use serial?”, ask Vinay.
“Yes, but our laptops don’t have a serial – hopefully USB to Serial converters would work”, replied Pugs.
“If it works, it would be great. We can then just connect the various serial port lines to the corresponding ATmega16 lines, and then write an application on laptop to download a ‘blink led’ program into the ATmega16”, supported Vinay.
“Regarding the application, we may not have to write one, as there is already one open source application called avrdude, specially for downloading or flashing programs into AVRs. We may just have to configure it properly”, replied Pugs.
“O! That’s good.”
“However, connecting the lines of ATmega16 to serial port may not be straight forward.”
“Why? That looks simpler than the flashing part.”
“Ya! but the challenge is that serial port lines operate on +/-12V – +12V being logic 0 and -12V being logic 1. And, micro-controllers understand 0/+5V – 0 being logic 0V and +5V being logic 1.”
“Oh! I didn’t know that there are things where 0 and 1 are not just 0V and 5V. Then, it might not be possible to connect them, right?”
“Don’t give up that easy. Where there is a problem, there would be a solution. Possibly there would be some way to do the proper voltage translations.”
So, they explored further about the same and figured out that ICs like MAX232 are meant exactly for such purposes. MAX232 datasheet gave them the connection details. Using that, they set up the ATmega16 and MAX232 connections, as shown in the schematic and breadboard diagram below. They also connected an LED through a resistor to port pin B0 for “blink led” program. Also, they set up the reset circuitry using the pull-up resistor and the jumper J1, as reset needs to be pulled low for downloading the program into ATmega16, and needs to be set high for running the program. So, J1 would be shorted, before starting the programming, and opened for running the flashed program.
Read More: Micro-controller Programming on a Bread Board
- How can a DIY learner program a microcontroller without external hardware?
By using AVR controllers with a serial programming mechanism controlled from a laptop. - What software is used to download programs into AVRs?
The open source application called avrdude is used for downloading or flashing programs. - Why is direct connection between serial port lines and ATmega16 not straightforward?
Because serial port lines operate on +/-12V while microcontrollers understand 0/+5V levels. - Which IC is used to translate voltage levels between the serial port and the microcontroller?
ICs like MAX232 are used specifically for such voltage translations. - Where should the LED be connected for the blink led program?
An LED through a resistor should be connected to port pin B0. - How is the reset circuitry configured for programming versus running the program?
The jumper J1 must be shorted before starting programming and opened for running the flashed program. - What pages of the datasheet explain the serial programming mechanism?
Pages 273-277 of the AVR ATmega16 datasheet detail the simple serial programming mechanism. - Can laptops directly use serial ports for this purpose?
No, laptops do not have serial ports, so USB to Serial converters are needed.


