From my understanding, in order to burn a C program to the ATMega32's flash memory, the program is first compiled and converted into a hex file which is then uploaded using a computer program such as avrdude using a USB connection to an AVR programmer let's say a USBasp. The AVR programmer then sends the data using SPI to the ATMega32 to be programmed.

Now this is my very superficial understanding of how this whole operation works, however I'm very confused on one part. That is, how does the microcontroller know that the incoming data from the USBasp is the program and not some sort of binary data to be stored in the data memory. Also what is the need for an ATTiny8 microcontroller in the USBasp, what exactly does it do?

I have been meaning to make my very own ATMega32 programmer from scratch, and I really want to comprehend what actually happens behind the scenes.

  • \$\begingroup\$ See: ww1.microchip.com/downloads/en/appnotes/… \$\endgroup\$ Dec 13, 2022 at 15:10
  • \$\begingroup\$ I didn't know this existed. Thank you, this is exactly what I need! \$\endgroup\$ Dec 13, 2022 at 15:29
  • \$\begingroup\$ Re, "what is the need for an ATTiny8 microcontroller...?" USB is hard. It's a complicated protocol. Your USBapp programmer has to communicate with the host computer via a USB connection, and simply identifying as a USB device requires some computing power. \$\endgroup\$ Dec 13, 2022 at 16:07
  • \$\begingroup\$ But from what I understand, avrdude actually translates the USB signals to SPI \$\endgroup\$ Dec 13, 2022 at 16:44
  • \$\begingroup\$ avrdude using a USB connection ... no .... avrdude knows nothing about USB ... avrdude uses a serial port connection ... the serial port is provided by the OS ... the underlying hardware is invisible to avrdude... the serial port could be a real hardware serial port or a virtual serial port that connects over USB, or even over internet \$\endgroup\$
    – jsotola
    Dec 13, 2022 at 18:28

1 Answer 1


The program is just binary data which happens to be the program.

The MCU is put into programming mode first, and then it is sent commands what to do, and programming commands provide info what memory address to program with what data.

The details about the protocol and commands are in the data sheet.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.