Homework and Reading for Servo Lab

ECE 4760, Adams/Land, Spring 2021

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:


Question 1

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?

Question 2

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.

Question 3

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.