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.

AM263P4: How to trigger a single cycle of ePWM Time Base module and then stop it

Part Number: AM263P4
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

Hello,

I am trying to do something that sounds trivial but I have not yet succeeded.

I want to generate a single pulse from an ePWM output upon a software trigger, e.g. 

EPWM_setTimeBaseCounterMode(CONFIG_EPWM0_BASE_ADDR, EPWM_COUNTER_MODE_UP); 

and then the ePWM module should on its own, without any ISR/software interaction, go back to Freeze mode. The reason why I do not want to use any ISRs is because the whole point of this exercise is to eliminate an ISR, which is triggered in the current implementation by a Timer to toggle the same pin and generate the same pulse. This ISR is interrupting the application control logic and messes up with motor current sensors timings.

In other words I want to use the Action Qualifier and manipulate the ePWM output pin only within a single 0-TBPRD cycle and then the TBCTR should either reset to 0 and stay there or remain at TBPRD, until another software call triggers the same behaviour again.

Is this possible to configure through SysCfg or other means? 

Everything I have tried so far (including OneShot through Global Load configuration and other similar options) has given me pretty much the same result, which is a combination of three pulses and then a single pulse.

This is my configuration:

Thanks!

  • Hi Manos, 

    May I ask why not use GPIO to achieve this instead of EPWM?

    Regards.
    Akshit

  • Hi Akshit,

    Because I am not aware of a way to set a GPIO high and then without a timer triggered ISR and of course without blocking the CPU with a counter, the GPIO will automatically set itself to low to achieve a specific pulse duration.

    My requirements are the following:

    • Trigger a single high pulse for a single GPIO/ePWM output, let's say EPWM1A.
    • This pulse shall be triggered periodically by the software at specific moments in scheduling.
    • The software will be to responsible to specify the pulse width for every iteration of the pulse.
    • The pulse shall be produced and controlled at the peripheral level, without any interaction of software, i.e. it shall not depend on a timed ISR to know when to transition from high to low. 
    • The one shot pulses will have a pulse width of either 10us or 50us as specified by the triggering software for any particular iteration.

    Regards,
    Manos

  • Hello,

    Is there any update on my request for support on this topic?

    Regards,

    Manos

  • Hi Manos, 

    Apologies, I got injured and was out on medical leave for a couple of weeks.

    Let me get back to you with a solution by tomorrow.

    Thank you so much for your patience!

    Regards,
    Akshit

  • Hi Manos,I 

    I think the initial pulses could be due to the time base counter starting from sysconfig in drivers_open(). 

    Instead of that could you try to set Time base counter mode to Stop-Freeze and start the counter in application code itself.

    // set the counter as 0 before starting
    EPWM_setTimeBaseCounter(baseAddr, 0);
    
    // trigger the one-shot sync event
    EPWM_startOneShotSync(baseAddr);
    
    // set the counter to run as UP-COUNT mode. It will now run for exactly one period
    //    and then stop because the one-shot sync event is done.
    EPWM_setTimeBaseCounterMode(baseAddr, EPWM_COUNTER_MODE_UP);

    Let me know if this solves the issue if not, we can try to disable all the global load settings in sysconfig an just use the time base sync event.

    Regards,
    Akshit

  • Just keeping this ticket alive since I'm taking over this topic from Manos.

  • Hello Manos, 

    Thanks for your patience here! Let's try to fix the issue quickly.

    You should be able to get a single software-triggered pulse from ePWM by combining one-shot sync with a frozen time-base. The key is to keep TBCTR stopped until we explicitly start one “cycle”, then have it stop again automatically at the end of that cycle.

    - Action-Qualifier for EPWMxA: Set output HIGH at ZRO, Clear output on CMPA (up-count)

    - Shadowing: Use shadow for CMPA with load on ZRO.

    - Disable Global Load one-shot.

    To ensure a known idle, you can force the output low once at init:

    EPWM_forceActionQualifierSWAction(uint32_t base, EPWM_ActionQualifierOutputModule epwmOutput)

    Make sure counter is frozen and starts from a known point:

    EPWM_setTimeBaseCounterMode(base, EPWM_COUNTER_MODE_STOP_FREEZE);
    EPWM_setTimeBaseCounter(base, 0);
    EPWM_setCounterCompareValue(base, EPWM_COUNTER_COMPARE_A, cmpa_ticks);
    EPWM_setTimeBaseCounterMode(base, EPWM_COUNTER_MODE_UP);
    
    
    

    Fire a one-shot sync so TBCTR will run exactly one cycle:

    EPWM_startOneShotSync(base);

    Please let me know if this resolved the issue.

    Best Regards,

    Masoud