Use avra assembler from source forge to generate hex file. The avra.exe windows executeable is available for download in reference “rclelectronics.blogspot.com”.
Following is the assembly code for led blink at portb pin 5, digital pin 13 on arduino.
.device ATmega32 .equ PORTB = 0x05 ;Port B .equ DDRB = 0x04 ;Data Direction Register Port B main: ldi r16,0x20 ;set port PB5 to output mode (pin5 is set for output, numbering starting at pin0) out DDRB,r16 clr r17 mainloop: eor r17,r16 ;invert output bit, eor=XOR operation out PORTB,r17 ;write to port call wait ;wait some time rjmp mainloop ;loop forever wait: ldi r20,0x10 ;loop 0x400000 times ldi r21,0x00 ;~12 million cycles ldi r22,0x00 ;~0.7s at 16Mhz w0: dec r22 brne w0 dec r21 brne w0 dec r20 brne w0 ret
- Use the following command to upload the hex code using “avrdude.exe”. The avrdude command is installed as part of fthe arduino ide package. In fact the following command has been copied from the arduino ide. The commands being executed in arduino ide can be made visible by selecting file>preferences>”show verbose output during uploading”.
“C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude.exe” -C”C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf” -v -patmega328p -carduino -PCOM3 -b115200 -D -Uflash:w:blink.hex:I