This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28379D: Measuring a PWM signal with Enhanced Capture

Part Number: TMS320F28379D

Hi,

I'm trying to measure a PWM signal with the enhanced capture module. The module seems perfectly adapted to measure an external PWM signal. However there's a catch. In my case, it is possible that the PWM will have its duty cycle stuck to 0% or 100%. Is there an easy way to work around this limitation?

My solution so far would be to use an eCap module and use an interrupt every 4 events (rising edge, falling edge, RE, FE). When this interrupt occurs, I would use a free-running counter to register the timestamp. Then, in my main loop, I would use the timestamp to see if the PWM measurement is still being updated. If it's not, I would flag it as the duty cycle being stuck on 0% or 100%.

Are there better solutions?

  • Hi,

    As you are measuring the duty, you could measure both the high and low pulse width.
    If the pulse width of a certain measurement exceeds the EPWM period (you know this from TBPRD) - then you can conclude that there is cycle of 0% or 100% duty based on which part exceeds the expected value. This option would only work if you know the expected frequency of waveform being measured.
    From your solution above it seems like you know the expected value of period as you are anticipating the PWM measurement based on a free-running timer.

  • The frequency should be fixed, but the wire could be sectionned and I would not measure anything, it would be stuck on 0 or 1 depending on the presence of a pull-up. Therefore I cannot assume that there will always be a PWM.


  • Hi,

    In that case have a timeout, like you have implemented, based on an independent timer would be the option.
    Have an independent timer that runs freely and is reset by Capture ISR frequently upon receiving an edge or configured number of edges.
    Set the timer to generate an interrupt when it exceeds certain period/overrun.
    So, in the normal operating conditions timer should never overrun. In case of the wire break or so, this timer would generate an interrupt detecting the error.
    Function would be similar to that of watchdog timer.