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 3.1 we are going to enable PORT B pin 5(PB5) as an output,
which is connected to the DISP DP net. This net controls DS1-DP
which is an active-low device.
TASK: Write assembly code such that when we enable PB5 as an output,
DS1-DP is dim.
TIP: Use the predefined register names and bitmasks from avr/io.h to
write your code.
*/
/** CODE: Write your code for Ex 3.0 above this line. */
/** Ex 3.1
TASK: Write assembly code to enable the pin connected to the DISP DP
net as an output.
*/
/** CODE: Write your code for Ex 3.1 above this line. */
/** EX: 3.2
In later exercises you will be required to read the state of
pushbuttons S1 and S4.
TASK: Write assembly code to enable the internal pull-up resistors
for the pins connected to these pushbuttons.
*/
/** CODE: Write your code for Ex 3.2 above this line. */
/** EX: 3.3
TASK: Write assembly code to illuminate DS1-DP.
*/
/** CODE: Write your code for Ex 3.3 above this line. */
// The code between the "loop_100ms" and "end_loop_100ms" labels will
// execute approximately 10 times per second.
loop_100ms:
/** EX: 3.4
TASK: Write assembly code to read the state of the BUTTON0 net and
store one of two distinct values in register R17.
- If S1 is pressed, R17 should contain zero as this net will be
connected to ground.
- If S1 is released, R17 should contain a non-zero value as the
internal pull-up resistor will pull the net to 3.3 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 BUTTON0 net.
*/
/** CODE: Write your code for Ex 3.4 above this line. */
/** EX: 3.5
The two instructions below check the value in R17 to determine
whether S1 is pressed.
When S1 is released, the "brne" (branch if not equal) instruction
will succeed (as R17 is not equal to 0). This will update the PC to
the location of the instruction which appears after "ex35_end",
skipping any code between "ex35_if" and "ex35_end".
TASK: Write assembly code to toggle the state of DS1-DP when S1 is
pressed.
*/
cpi r17,0// Compare R17 with 0
brne ex35_end // branch to "ex35_end" if R17!=0
ex35_if:
/** CODE: Write your code for Ex 3.5 below this line. */
/** CODE: Write your code for Ex 3.5 above this line. */
ex35_end:
end_loop_100ms:
// The code between the "loop_10ms" and "end_loop_10ms" labels will
// execute approximately 100 times per second.
loop_10ms:
/** EX: 3.6
At the start of this program, some code was included to set up the
Timer Counter A 0(TCA0) peripheral to synthesise a 200 Hz waveform
to drive the piezo buzzer connected to the BUZZER net.
TCA0 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 S4 is pressed, and not driven (silent), when S4 is released.
HINT: The code to read the state of the BUTTON3 net should be
similar to what you wrote in Ex 3.4.
*/
/** CODE: Write your code for Ex 3.6 below this line. */
cpi r18,0// Compare R18 with 0
brne ex36_else // branch to "ex36_else" if R18!=0
ex36_if:
rjmp ex36_end // Ensure the program skips over the else block
ex36_else:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!