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.

CCS/TMS320F28379D: Capture Sine Input Frequency

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

Hello all,

i want to capture the frequency of an input sine to synchronize an output frequency.

Therefore i use the CMPSS Module to catch the frequency. I used the follwing Moduls like described:

At CMPIN1P i insert the input Sinewave. DACHVALS is set to the half of the Vpp of the input sinewave. The result of the comparator sets the output CTRIPH asynchronus.

The signal CTRIPH goes through ePWM X-Bar to the PWM-Module.

The signal goes through TRIPIN4 to EVENT A QUAL to the Event Filtering.

There i want to capture the time between 2 Edges with the CNTVAL. This value shall be copied to TBPRD register. I tried to show the issue in an Timing Diagramm:

Until DCAEVT1 everything works like i expected. The DCAEVT1 lasts for 10ms (half sine period of input sine 20ms). I want to count the time when DCAEVT1 is one to synchronize the output PWM with the input frequency. The PWM module uses upcount_downcount_mode.

I tried to catch this time with the Edge Capture Logic. With the SW Trigger i should be able to start the measurement with the next Edge of DCAEVT. Then the counter starts to count until the next Edge. When i read the Register VCNTVAL it is zero. So it was not successfull.

My TBCLK is configured to 200 MHz. That means the counter increases the value every 5 ns. With an increasing time of 10ms (DCAEVT1) the countervalue will be 2000000. But the Timer is only 16-bit (65535 is maximum). When i change the TBCLK to a lower frequency i lose precision in generating the output PWM.

Sorry for the bad description i hope there is any  solution for this problem?

Best regards,

Martin

  • Hi Martin,

    I think there is actually a simpler solution to this. Instead of using the CMPSS + EPWM, use the CMPSS + ECAP. One of the ECAP's main functionality is to measure frequency. What you will need to do is output the CMPSS to the OUTPUTXBAR and use the INPUTXBAR to tap that and feed it to the ECAP.
  • Hi Frank,

    thank you for your answer. This solution seems much simpler than my previous thoughts.
    But i don't detect an internal connection possibility between the OUTPUTXBAR and the INPUTXBAR to connect CMPSS to ECAP.
    With the OUTPUTXBAR i can only drive GPIOS if i didn't overlook something. So do i need to drive a output GPIO and read back over an physically connected input GPIO with is connected to ECAP over INPUTXBAR or is there any other solution to connect these Periphals internally?

    Best regards,
    Martin
  • Martin,

    The INPUTXBAR can tap every GPIO. On the F28379D device, INPUTXBAR7..12 to go ECAP1..6 respectively.

    As an example, let's say you are routing the CMPSS output to GPIO14 through OUTPUTXBAR3 and you are using ECAP1 to capture it. Only INPUTXBAR7 goes to ECAP1. You then configure INPUTXBAR7 to tap GPIO14 using (InputXbarRegs.INPUT7SELECT = 14). If you need help on how to configure the ECAP to measure frequency, we have some useful examples in C2000Ware that you can take a look at. Let us know if it's not clear.
  • Hi Frank,

    i routed the signal over OUTPUTXBAR5 to GPIO7 and read it back over the InputXbarRegs.INPUT7SELECT = 7 as you explained.

    I first tried to measure the frequency in continous mode like in Example 3 chapter 16.6.3 of the Technical Reference Manual. But the measuring result was not usable. It was really randomly.

    With the help of the example "ECap_Capture_Pwm_cpu01" of C2000Ware is got a useful result with a good resolution in oneshot Mode. Now i am able to synchronize my ouput PWM frequency with the input frequency.

    Thanks for the help :)

    Martin

  • Glad to have helped. Let us know if you ran into anymore issues.