Hi all, first post to the forum, but I have already learned a lot from reading the excellent material available!
My aim on this thread is to measure duty cycle and width of an external PWM signal. I am developing on the LaunchPad with the now called TM4C1233H6. Workspace is IAR.
My PWM signal inputs to Timer2A via PF4 pin. Its typical width is 990us. The duty cycle can be as small as a 1us ON time (image below displays the signal at 18% duty cycle, with 178us ON time).
Timer2A is configured as half width (16bit), capture mode counting up (TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_CAP_TIME_UP), and the interrupt is enabled for BOTH_EDGES.
Measuring strategy is to read the TAR whenever it triggers a capture, and at the same time read the GPIO of PF4 to determine if the board was going up or down. The difference between two "going up" borders is the width, and the difference between "going down" minus "going up" is the proportional ON time. The reason why the full width is read, and not only assumed constant, is because the sensor that generates the signal is a little unstable, and can vary the full width by about 1%.
All working good so far, but on the edges of the sensor range, the 1us interval is too short to treat the interrupt routine and properly read the timers before the opposite border capture would happen.
So the idea is to DMA two values to a buffer area in memory: the Timer2A TAR register AND the GPIO F register at the moment of the border interrupt, so that the processor can deal with calculations later when there is free time. Because of the other processing tasks, I would like a buffer with some 16 readings of those two registers. The DMA transfer should circle back to the first address, after storing into location #16.
I am still on the very first steps of DMA (I should say crawling), but I can't quite understand how to transfer TWO peripheral values via DMA triggered by one same interrupt (the event capture of the GP Timer). I would appreciate suggestions for this solution (and actually even for the more basic task of transferring only the Timer2 TAR register via DMA).
Thanks in advance!