In order to complete the first lab checkout on time, the following reading and problems should be completed before the start of the first lab section for this lab.
All of the readings from Labs 1, 2, and 3 plus:
- The lab webpage. - It is extremely critical that you read the entire webpage for this lab before the start of the first lab section.
- Timers (Reference Manual Section 14) - review the part about chaining 2 16-bit timers to create a 32-bit timer
- Output Compare (Reference Manual Section 16)
- PLIB Manual (Section 13)
The servo motors require a PWM period of 20 ms. At a CPU rate of 40 MHz, how many CPU cycles correspond to 20ms? How many bits are required to represent that number of cycles?
You may find, based on your answer to Question 1, that you require a timer with more than 16 bits. Which two timers can be chained to create a 32-bit timer? Write the code that chains these two timers and sets up an interrupt to trigger every 20ms.
Write the code that opens Output Compare 3 on RPA3 and Output Compare 4 on RPA2. Both of these should be opened in 32-bit mode, and should use the chained 32-bit timer.