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.

TMS570LS1224: Two HET1 pwm1, pwm2 Notification

Part Number: TMS570LS1224
Other Parts Discussed in Thread: HALCOGEN

Hello TI-Support

I would like to configure two pwm signals.

pwm1: period 10'000 us

pwm2: period 2'000 us

I would then like to enable pwm notification for both signals, however so far only notifications for pwm1 are received but none for pwm2.

Here is my code:

int main(void)
{
    _enable_IRQ();
    _pmuInit_();
    _pmuEnableCountersGlobal_();

    GlobalTestCounter1 = 0;
    GlobalTestCounter2 = 0;

    hetSIGNAL_t PWMSignal;
    /*Initialise the HET1 timer signal pwm1 */
    PWMSignal.duty = 50; //Set PWM duty cycle in %
    PWMSignal.period = 10000; //Set PWM period in us
    pwmSetSignal(hetRAM1, pwm1, PWMSignal); //set the PWM duty-cylce and period

    /*Initialise the HET1 timer signal pwm2 */
    PWMSignal.duty = 50; //Set PWM duty cycle in %
    PWMSignal.period = 2000; //Set PWM period in us
    pwmSetSignal(hetRAM1, pwm2, PWMSignal); //set the PWM duty-cylce and period

    /*initialise the HET1 timer module */
    hetInit();
    
    pwmStart(hetRAM1,pwm1);//enable the pwm signal, which triggers the adc conversion
    pwmEnableNotification(hetREG1,pwm1, pwmEND_OF_PERIOD); /* enable the pwm1 end of period notification */
    pwmStart(hetRAM1,pwm2);//enable the pwm signal, which triggers the adc conversion
    pwmEnableNotification(hetREG1,pwm2, pwmEND_OF_PERIOD); /* enable the pwm1 end of period notification */
    while(1)
    {
    }
}


void pwmNotification(hetBASE_t * hetREG,uint32 pwm, uint32 notification)
{

    /*verify notification source */
    if(pwm == pwm1)
    {
        GlobalTestCounter1++;

    }

    /*verify notification source */
    if(pwm == pwm2)
    {
        GlobalTestCounter2++;
    }
    return;
}

In HalCoGen I configured pwm1 and pwm2 in the same way. Since I do get pwm notifications for pwm1 I guess the HalCoGen configuration is fine.

What am I doing wrong here?

  • Hi Simon,

    I started to look into your issue and i will get back to you soon with an update.

    --
    Thanks & Regards,
    Jagadish.

  • Hi Simon,

    Are you not using HALCoGen for your code generation, if you use HALCoGen then no need to configure Period and Duty cycle in your code you can just configure required parameters in HALCoGen GUI itself

    I am attaching one reference project to you here, you can refer this project

    PWM_on_HET_LS3137.zip

    On this project i am generating two PWM's using HET peripheral with periods of 10mSec and 2mSec on the pins of HET1_28 and HET1_30 respectively. I verified waveforms and also notification interrupts and it is working fine.

    --
    Thanks & Regards,
    Jagadish.

  • Hi Jagadish

    Thanks for the reference project. The two timers are working now. However, I have a related issue.

    I configured pwm1 with a period of 4 us and pwm2 with a period of (1s - (4us * 4992). In my code I start with only enabling pwm1. After 4992 EoPeriod-Notifications from pwm1 I stop pwm1 and start pwm2. At the EoPeriod-Notification of pwm2 I stop pwm2 and restart pwm1.

    I would expect an EoPeriod notification from pwm2 after 1s (pwm2-period + 4992*pwm1_period). However, I measure an EoPeriod notification from pwm2 every pwm2_period.

    This is my Code:

    int main(void)
    {
        _enable_IRQ();
    
        /*initialise the GIO module */
        gioInit();
    
    
        /*initialise the HET1 timer module */
        hetInit();
    
        hetSIGNAL_t PWMSignal;
        PWMSignal.duty = 80; //Set PWM duty cycle in %
        PWMSignal.period = 4; //Set PWM period in us
        pwmSetSignal(hetRAM1, pwm1, PWMSignal); //set the PWM duty-cylce and period
    
        PWMSignal.duty = 20; //Set PWM duty cycle in %
        PWMSignal.period = (1000000-(4*4992)); //Set PWM period in us
        pwmSetSignal(hetRAM1, pwm2, PWMSignal); //set the PWM duty-cylce and period
    
        pwmEnableNotification(hetREG1,pwm1, pwmEND_OF_PERIOD); /* enable the pwm1 end of period notification */
        pwmDisableNotification(hetREG1,pwm2, pwmEND_OF_PERIOD); /* enable the pwm2 end of period notification */
    
        pwmStart(hetRAM1,pwm1);
        pwmStop(hetRAM1,pwm2);
        gioToggleBit(gioPORTA,BIT_7);//GIOA[0] = 0 -> RXen (low active)
    
        GlobalTestCounter2 = 0;
    
        while(1)
        {
    
            if(GlobalTestCounter0 > 10)
            {
                while(1)
                {
                }
            }
            if(GlobalTestCounter1 > 10)
            {
                while(1)
                {
                }
            }
        }
        return 0;
    }
    void pwmNotification(hetBASE_t * hetREG,uint32 pwm, uint32 notification)
    {
        /*verify notification source */
        if((hetREG == hetREG1) && (pwm == pwm1) && (notification == pwmEND_OF_PERIOD))
        {
            GlobalTestCounter2++;
            if(GlobalTestCounter2 == 4992)
            {
                pwmDisableNotification(hetREG1,pwm1, pwmEND_OF_PERIOD);
                pwmStop(hetRAM1,pwm1);
                pwmStart(hetRAM1,pwm2);
                pwmEnableNotification(hetREG1,pwm2, pwmEND_OF_PERIOD);
            }
        }
    
        /*verify notification source */
        if((hetREG == hetREG1) && (pwm == pwm2) && (notification == pwmEND_OF_PERIOD))
        {
            pwmDisableNotification(hetREG1,pwm2, pwmEND_OF_PERIOD);
            pwmStop(hetRAM1,pwm2);
            pwmStart(hetRAM1,pwm1);
            pwmEnableNotification(hetREG1,pwm1, pwmEND_OF_PERIOD);
            GlobalTestCounter2 = 0;
            gioToggleBit(gioPORTA,BIT_7);//GIOA[0] = 0 -> RXen (low active)
        }
        return;
    }
    

    I use the GIOA_Bit7 toggle to measure the timing

    Basically what I would like to accomplish is to have pwm1 run for 4992 cycles, then pause for an specific time and run for 4992 cycles again.

  • Hi Simon,

    Are you getting same waveform as below

    First signal is PWM1 which is generating 4992 pulses and PWM2 should be started after PWM1 but it is starting at the same time with PWM1. This is the behavior you observed on your end right?

    --
    Thanks & Regards,
    Jagadish.

  • Hi Simon,

    I understood the root cause for the behavior we are seeing. 

    Basically, pwmStart and pwmStop functions only stops the PWM signal on output pins and these functions will not stop internal counter and compare functionalities. That means when we call these functions the entire internal PWM functionality will happen as it is except, we can't see the waveforms on external pins.

    Also, you should know one more thing, i.e. when you try to start pwm again (i.e. want to reflect the wave form on port pin) it won't get starts immediately, it will get starts only after completing of period of the corresponding waveform. This is because of double buffering behavior, for smooth waveform generation the internal code for N2HET module is written in such way that the changes in middle of the period will get execute only after completion of the current period.

    Please go through below image and read from left to right then you can understand the behavior clearly.

    I would like to suggest one workaround to achieve your intentional behavior.

     

    Use highlighted instruction for to start PWM2 instead of pwmStart function, don't do any other modifications except this. Actually, this instruction is like bypassing double buffering and the PWM2 waveform will get starts immediately. But remember you have to adjust your period and duty cycles here because PWM2 timer counter already completed some counting before reaching to here and just waveform is starting here.

    --
    Thanks & Regards,
    Jagadish.

  • Hello Jagadish

    Thanks for the clarification and workaround!

    Simon