I would like to understand how to configure ports (port, ddr, pin) using avr atmega328p Assembler

Asked

Viewed 219 times

0

Example that was testing, configure output ports and input ports, to be able to perform a sum, but are not working:

ldi r21, 0x0a
ldi r22, 0x0b

out PINB, r16
out DDRB, r16
out PORTB, r17

add r21, r22
mov r17, r21

1 answer

0

  1. A Nibble (half byte) is being loaded in R16. Normally the right is 0x0a or 0xa0.
  2. 0xa0 in DDRB is equal to 0b10100000 which activates for output pins 7 and 5. While 0x0a is equal to 0b00001010 which activates for output pins 1 and 3.
  3. To read a door door the correct is:

    In  r16, pinb
    
  • Reply on mobile is not good ...

  • Correcting the question because I did not understand your answer...

  • Part of this example: http://www.avr-tutorials.com/digital/digital-input-output-assembly-programming-atmel-8-bits-avr-microcontrollers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.