User Tools

Site Tools


using_avr-gcc

Using with avr-gcc

ledon.S
;;;;   assemble with:-    avr-gcc -c ledon.S 
;;;;   the output file produced is ledon.o
;;;;   use:- avr-objcopy -O ihex ledon.o ledon.hex to get intel hex file
;;;;   upload this file to the arduino using avrdude:-
;;;;   avrdude -p m328p -c Arduino -P /dev/ttyACM0 -b 115200  -Uflash:w:ledon.hex:i -v -v
 
; Load the binary pattern 11111111 into Register 16	              
LDI    R16,  0b11111111 
 
; send all the 1s to the Data direction register at address 0x04
; to configures all lines on Portb  as an Outputs      
OUT    0x04, R16              
 
 
; not really needed, already loaded wits 1s.
;but later if we put all zeros here the LED would go off 
LDI    R16,  0b11111111
 
 
; Send all the 1s to all lines on port B at address 0x05. 
;A 1 takes the line up to 5 volts and lights the LED
;A 0 takes the line down to 0 volts and the LED goes off.     
OUT    0x05, R16             
 
; If we had an LED connected to each line of port b, they would all light up.
 
 
stop:
rjmp stop                    ;don't run on past end of program 
 
using_avr-gcc.txt · Last modified: 2018/08/10 20:15 (external edit)