Question: In Ex 3 . 1 we are going to enable PORT B pin 5 ( PB 5 ) as an output, which is connected to
In Ex we are going to enable PORT B pin PB as an output,
which is connected to the DISP DP net. This net controls DSDP
which is an activelow device.
TASK: Write assembly code such that when we enable PB as an output,
DSDP is dim.
TIP: Use the predefined register names and bitmasks from avrioh to
write your code.
CODE: Write your code for Ex above this line.
Ex
TASK: Write assembly code to enable the pin connected to the DISP DP
net as an output.
CODE: Write your code for Ex above this line.
EX:
In later exercises you will be required to read the state of
pushbuttons S and S
TASK: Write assembly code to enable the internal pullup resistors
for the pins connected to these pushbuttons.
CODE: Write your code for Ex above this line.
EX:
TASK: Write assembly code to illuminate DSDP
CODE: Write your code for Ex above this line.
The code between the "loopms and "endloopms labels will
execute approximately times per second.
loopms:
EX:
TASK: Write assembly code to read the state of the BUTTON net and
store one of two distinct values in register R
If S is pressed, R should contain zero as this net will be
connected to ground.
If S is released, R should contain a nonzero value as the
internal pullup resistor will pull the net to V
HINT: Use the IN register to read the state of the entire pinset on
PORTA, and then use a bitmask and bitwise operation to isolate only
the bit corresponding to the pin connected to the BUTTON net.
CODE: Write your code for Ex above this line.
EX:
The two instructions below check the value in R to determine
whether S is pressed.
When S is released, the "brne" branch if not equal instruction
will succeed as R is not equal to This will update the PC to
the location of the instruction which appears after exend",
skipping any code between exif and exend".
TASK: Write assembly code to toggle the state of DSDP when S is
pressed.
cpi r Compare R with
brne exend branch to exend" if R
exif:
CODE: Write your code for Ex below this line.
CODE: Write your code for Ex above this line.
exend:
endloopms:
The code between the "loopms and "endloopms labels will
execute approximately times per second.
loopms:
EX:
At the start of this program, some code was included to set up the
Timer Counter A TCA peripheral to synthesise a Hz waveform
to drive the piezo buzzer connected to the BUZZER net.
TCA will automatically override the output of the pin connected to
the BUZZER net, however, the pin needs to be configured as an output
for the waveform to define the state of the BUZZER net.
TASK: Write assembly code such that the buzzer is driven audible
when S is pressed, and not driven silent when S is released.
HINT: The code to read the state of the BUTTON net should be
similar to what you wrote in Ex
CODE: Write your code for Ex below this line.
cpi r Compare R with
brne exelse branch to exelse" if R
exif:
rjmp exend Ensure the program skips over the else block
exelse:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
