Deepak Status Report 10/19/2019

Deepak Status Report 10/19/2019

This week I worked on getting the timers to trigger the ADC. The ADC must be triggered at a specific time in the PWM cycle, so naturally I first tried to generate the trigger from the timer generating the PWM. When I got the ADC triggering properly and data coming over UART, there seemed to be no PWM output. I confirmed this with an oscilloscope, and experimented until I realized I could not get the PWM and ADC triggering to both work on the same timer.

From there, I decided to use the timer synchronization feature of the microcontroller, where multiple timers can be chained together in various ways. I set up the PWM timer to simultaneously start another timer upon activation. This secondary timer would then be used to trigger the ADC. I increased the prescalers of each timer by a few orders of magnitude in order to slow the counter to a human-readable speed. Over UART, I confirmed that starting the primary (PWM) timer would start the secondary timer by viewing each timer’s counter. I reduced the timer prescalers back to their original values, then looked on UART again and it seemed that the timers were counting at different rates. This seemed impossible, since they were started at the same time and both were set to count at the same rate. If the timers are not synchronized, then the ADC would not be triggered at the correct time. I raised the prescalers again, then watched the counter values for a few minutes. Even at a much lower speed, the timers still became desynchronized from each other.

The next thing to try is using one timer as a prescaler for another. Specifically, using the PWM timer as a prescaler for a secondary timer. This will keep the timer counters synchronized, and should allow me to trigger the ADC from the secondary timer at the correct time in the PWM cycle.

Leave a Reply

Your email address will not be published. Required fields are marked *