Question

I am about to start working on a project for which ATmega328P seems a good option. However I was trying to program it using its instruction set rather than using AVR's C library. This posed a problem of converting and burning the program to Atmega's flash memory. How can this be done?

Was it helpful?

Solution

I understand, that you have your code in AVR assembly language. If so, you need avr-assembler. On linux systems this program is called avr-as and it's a part of avr-binutils package. On windows machine I recommend installing "winavr" suite - it has same tools and even some eye candy IDE to ease some processes.

Once you have this covered, run your assembler on your code.

avr-as -mmcu=atmega328p  o my_program.elf my_code.asm 

If everything builds cleanly, you will still need to convert the output into .hex format. This can be done using avr-objcopy (from the same packages).

avr-objcopy -O ihex my_program.elf my_program.hex

After this you should have my_program.hex ready to be programmed into your controller.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top