EECS 373 Lab 4: Interrupts - Answer Sheet

Name and Unique Names

 

 

 

Instructor sign-off

 

Post lab 1: _______________________________________

 

Post lab 2: _______________________________________

Questions

Q: In Lab 3, you had two modules attached to the APB3 bus. What is the difference in bytes between the memory mapped addresses of the two modules? (Hint: Use the Modify Memory Map function in Libero)

 

 

 

Q: Look inside ReadSW_WriteLEDs.v. What input wires/variable determines which register (led or sw) are accessed? What is connected to subAddr in the wrapper? Why do we only use the lower 8 bits of the PADDR?

 

 

 

Attach a screenshot (using camera) or a hand drawing of a bouncing switch.

 

Q: Explain in a few sentences how the synchronization block synchronises the input switch.

 

 

 

Q: Why is the switch input inverted?

 

 

 

Q: What happens if the SW[0] pulse is shorter than one PCLK period?

 

 

 

The next question is on the robust synronization block:

Q: How does this code solve the shorter than one PCLK period SW[0] pulse problem?

 

 

 

Q: Pause your debugging session and add a breakpoint to one of the interrupt service routines. Resume the operation and hit one of the switches. Your debugger should stop right at your breakpoint. Inspect the disassembled code. Which registers are used by the interrupt routine? And what does the __attribute__ ((interrupt)) do?

 

 

 

Q: Explain in two sentences why we have the text Wait For Interrupt in between every interrupt service routine.

 

 

 

Q: Explain in a few sentences what the MSS_GPIO_* functions exactly do. Especially, which registers do they modify? What other functions are provided by the MSS_GPIO drivers? List all of them with one sentence per function explaining its purpose.

 

 

 

Q: Run the application you just wrote on your board and connect a serial terminal to the serial port. Push the switch several times. Which of the two interrupts fires first? Compare it to your answer that you just wrote down. Explain in two sentences why this interrupt gets handled before the other one.

 

 

 

Q: Perform 10 latency measurements. What is the mean time and standard deviation of your measurements?

 

 

 

Q: Perform 10 latency measurements with PRIMASK. What is the mean time and standard deviation of your measurements? Explain the behavior in two sentences.

 

 

 

Q: Explain the output behavior in 2 sentences. The character shifts are due to slight time drift in the system.

 

 

 

Q: Explain at least two methods on how to avoid this problem. Hint: PRIMASK

 

 

 

Post-Lab Assignment

Part 1: Write a debouncer for the switches, either in assembly (hint: clear interrupt flags) or in verilog (hint: counters). The concept of the debouncer is simple: after the first switch event detected, ignore any subsequent events from that switch for a short period of time.

Part 2: Write a memory mapped verilog component device that generates an interrupt every X clock ticks. Make this component into a peripheral such that the Cortex-M3 can start, stop, reset, and change X by writing to its registers. Write a small application using your peripheral and toggle an LED whenever your peripheral generates an interrupt.