how to define the ports in Arduino from assembler language?

0

I am trying to learn Arduino programming in assembler, using as an Arduino UNO R3 board and based on the examples of this tutorial: link

I have managed to assemble and record the blink of the first example, which lights an LED connected to pin 13 of the board.

But I would be interested in being able to change the output pin, so instead of using pin 13, use another pin, such as 3.

How could that change?

    
asked by AlmuHS 03.05.2017 в 22:10
source

1 answer

2

Finally I found it, in these two lines

ldi r16,0x20 ; set port bits to output mode
 out DDRB,r16

The first line says the pin to be used, which is defined by setting its position to 1. Position 5 would be 100000, which in hexadecimal is 20, hence the first instruction. If I wanted to put position 3 I would put 1000, 8 in hexadecimal.

And the port is defined with the DDR *, putting DDRB, DDRD, or the corresponding one.

Finally, the correspondence between the pins of the board and those of the microcontroller is here: link

So, with those two data, I've already been able to define the pins I want to use

    
answered by 11.05.2017 / 17:03
source