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.

eCAP - measurement of duty cycle (0% - 100%)

Other Parts Discussed in Thread: HALCOGEN

Hi there,

we shall use the eCAP module of the RM46 (ZWT-package) to measure the duty cycle of a 50Hz-PWM signal.
The signal is connected to ECAP1 - PIN 'N1'.

It's easy for PWM Signals, which can not reach 0% or 100% duty cycle.
But the signal, that we shall measure, can go from 0% to 100%.

Thus, there will be no captures, if PWM is 0% or 100%.

- maybe you have a good hint for me, how to catch 0% and 100% PWMs?

- is there a way to read out the actual value of the ECAP1 ("N1") pin? (similar to GIO?)
-> EDIT: I think, I solved this 'read PIN' question:
                  - ECAPx pins are readable via HalCoGen Driver.... :
                  - ECAP1 shall be readable via HalCoGen Driver:  "gioGetBit(hetPORT1, 15U)"
                  - ECAP2 shall be readable via HalCoGen Driver:  "gioGetBit(spiPORT3, 11U)"

Thanks in advance,

Andy

  • Andy,

    You may want to consider the following approach.

    (1) At system level, define a period of time. If there is no capture in this period, the input signal is considered as 100% or 0% duty cycle depending on the state of the pin.

    (2) In eCAP setup, reset the counter at one edge of the pulse. You can choose the rising edge.

    (3) Set up an compare interrupt with the period you defined earlier. When this interrupt occurs, the input is either 0% or 100% duty cycle depending on the pin state.

    (4) You cannot directly read the pin state from eCAP module. You need to read from the other module which has a pin muxed with eCAP (you already figure it out). On those pins, only the output buffer are muxed. The inputs are tied together. To read from the other module, you need to make sure that it is out of reset.

    Thanks and regards,

    Zhaohong