I am trying to solve the question below for the two blank lines of code and I am starting to confuse myself. Can anyone help me with what code should be filled in and why so.
Assume that pins 4 and 2 on PORTA are connected to an additional output device (DevD). Fill in lines 1-2 such that the corresponding pins are specified as outputs. Do not configure any other pins on the port as outputs.
.include “m128def.inc”
.def mpr = r16
START:
.org $0000
JMP INIT
.org $0004
RCALL ISR_DevA
RETI
.org $000C
RJMP ISR_DevB
NOP
.org $0010
RJMP ISR_DevC
INIT:
ldi mpr, 0b00110000
sts EICRA, mpr
ldi mpr, 0b11101000
out EICRB, mpr
ldi mpr, 10100010
out EIMSK, mpr
ldi mpr, $00
out DDRD, mpr
out DDRE, mpr
(1) ________________
(2) ________________
sei
...
You can specify pin as output or input in AVR microController by writing to a register called DDRx
(Data Direction Register)
for every pin in port A there is a corresponding bit in DDRA
register Control if this pin is work as output or input (1 mean output, 0 mean input)
to make pins 4 and 2 on PORTA
as ouptut you have to put '1' in corresponding bit this mean you have to write the value 0b00010100
in register 'DDRA'
ldi r16, 0b00010100 ; put the value in r16 register
out DDRA, r16 ;write to the DDRA the value in r16