In this assignment, you will use both timer and switch interrupts to control the two simple LEDs on your PIC32MM Curiosity Development Board as follows:
• Each timer interrupt should change the LEDs to one of the states shown below, in the order shown (go from state 1 to state 2, 2 to 3, 3 to 4, and from 4 back to 1):
1. Both LEDs off
2. LED1 off, LED2 on
3. LED1 on, LED2 off
4. Both LEDs on (return to state 1 after leaving state 4)
The initial timer configuration should use a prescaler of 256 and period of 0x0FFF
• Each switch interrupt should modify the timer delay as follows:
Pressing S1 should multiply the delay by 2
Pressing S2 should divide the delay by 2
NOTE: Don’t use multiply/divide instructions—there’s an easier way!
• Set minimum/maximum delays as follows:
Your initial delay is the minimum possible delay
Since the timer period register PR1 is only 16 bits, the maximum possible delay is a period of 0xFFF0
• If S1 pressed when delay is at maximum, cycle back to the minimum delay
So, increasing timer periods follow this pattern:
0x0FFF 0x1FFE 0x3FFC 0x7FF8 0xFFF0 0x0FFF (return to initial state) •
If S2 pressed when delay is at minimum, cycle back to the maximum delay
So, decreasing timer periods follow this pattern:
0xFFF0 0x7FF8 0x3FFC 0x1FFE 0x0FFF 0xFFF0 (return to max delay)