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.

TMS570LC4357: Can I synchronize the beginning (count=0) of both the PWM-outputs and the N2HET-outputs?

Part Number: TMS570LC4357

Tool/software:

I asked this question a few months ago, and I finally got back to investigating it. The problem with using the N2HET loop-sync as the sync-in for the EPWM, is my N2HET loop period is ~333ns, and my EPWM period is 25us. 

In order to try to set both the EPWM and N2HET as a 40Khz PWM period, the N2HET loop-period is ~333ns, and the N2HET CNT is 75 (0 to 74), but the EPWM TBPRD is 1875 at this clock rate.

What I want to do, is align the beginnings (count = 0) of both N2HET and EPWM -- but also allow each peripheral to fully count up. Using the N2HET loop-sync essentially resets the EPWM to 0 every 333ns, so the EPWM never runs.

The only way I can see to possibly do this is to use the N2HET to drive an external pin at CNT=0, which is shorted to the external ePWM1SYNCI, and the EPWM would sync on this external input? Can you think of another idea?

Thanks,

Jim

  • Hi Jim,

    The only way I can see to possibly do this is to use the N2HET to drive an external pin at CNT=0, which is shorted to the external ePWM1SYNCI, and the EPWM would sync on this external input? Can you think of another idea?

    I don't have any other better ways to suggest.

    However, why don't you use eCAP module for PWM generation instead of NHET. Because we can easily sync the ePWM and eCAP modules.

    (+) TMS570LC4357: PWM - Arm-based microcontrollers forum - Arm-based microcontrollers - TI E2E support forums

    --
    Thanks & regards,
    Jagadish.

  • Thanks; I will look into using ECAP.

    Another question for you -- can I restart the N2HET from the CPU?

    My N2HET period and my PWM-ISR period are both 25us, so in my PWM-ISR, I tried:
    GCR.TO = 0 (OFF)
    wait for the N2HET period to complete
    Update all N2HET-edge data values
    Set the N2HET CNT data field = 0
    GCR.TO = 1 (ON)

    The N2HET does not seem to restart after this; is there a way I can reset the N2HET CNT to 0
    and restart it -- every N2HET PWM cycle?

    Thanks,

    Jim

  • Hi Jim,

    GCR.TO = 0 (OFF)
    wait for the N2HET period to complete
    Update all N2HET-edge data values
    Set the N2HET CNT data field = 0
    GCR.TO = 1 (ON)

    This reset procedure looks fine for me. I don't know why it is not working.

    Can i get your code to test and see how you are set the data filed =0?

    --
    Thanks & regards,
    Jagadish.

  • Jagadish,

    Thank you for the offer, but I am not permitted to send out code. I spent a couple of hours trying to pull out this small amount of functionality into a separate project, and it appears to be a significant task. I think we are going to pursue the external PWM-sync pin. 

    Thanks,

    Jim

  • Jagadish,

    This issue has become serious enough that I may be able to send you my source code, if your offer is still valid. If so, is there a way I can send this code to you outside this public forum -- so that only you are the recipient? I am still going through channels here to see if I could still send it to you, but I know it would only be possible outside this forum? 

    Thanks,

    Jim

  • Hi Jim,

    if your offer is still valid. If so, is there a way I can send this code to you outside this public forum -- so that only you are the recipient?

    You can send it through private chat window, no one else will have access to it.

    I just sent you a friend request accept it and send private message.

    --

    Thanks & regards,
    Jagadish.