2013-05-20 09:12 AM
I have an external device that I need to measure it's utilization. I don't need code but I value the discussion and techniques offered. target is STM32F407
The external device outputs a pulse. minimum pulse width is 5ms and max is undefined, could be as much as one second high. A good analogy is a PC disk drive light. totally random utilization.I need to measure the area under the curve, which is the amount of time (per some sample interval, say 100ms, 200ms) that the signal is high vs low.A gated input capture is where I thinking of starting but I'm real new to ST timmers. #timers-input-capture2013-05-20 09:35 AM
The frequency is quite low.
You could use the input capture mode, and latch the timebase (CNT) into a CCRx register on the rising/falling edge. The transition will cause an interrupt, you read the CCRx out and compute a delta wrt the previous edge. This will be in ticks of the time base. One of the 32-bit timers would permit fine granularity, and long wrap times. A secondary channel could presumably be set in output compare mode where the CCRx is advanced by the integration period and a interrupt generated to compute the current ON time for the other signal.