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.

Workaround for N2HET PWM issue

Part Number: TMS570LS0432
Other Parts Discussed in Thread: HALCOGEN

Hi All,

 

I investigate the workaround for this HET PWM issue (HET Issue: Cannot stop pwm output, if duty cycle was set to 100%).

The following is the code of the pwmSetDuty() function generated by HALOCGEN(v04.07.00).

 

 

void pwmSetDuty(hetRAMBASE_t * hetRAM, uint32 pwm, uint32 pwmDuty)

{

   uint32 action;

   uint32 pwmPolarity =0U;

   uint32 pwmPeriod = hetRAM->Instruction[(pwm << 1U) + 42U].Data + 128U;

   pwmPeriod = pwmPeriod >> 7U;

 

   if(hetRAM == hetRAM1)

   {

       pwmPolarity = s_het1pwmPolarity[pwm];

   }

   else

   {

   }

   if (pwmDuty == 0U)

   {

       action = (pwmPolarity == 3U) ? 0U : 2U;

   }

   else if (pwmDuty >= 100U)

   {

       action = (pwmPolarity == 3U) ? 2U : 0U;

   }

   else

   {

       action = pwmPolarity;

   }

 

   hetRAM->Instruction[(pwm << 1U) + 41U].Control = ((hetRAM->Instruction[(pwm << 1U) + 41U].Control) & (~(uint32)(0x00000018U))) | (action << 3U);

   hetRAM->Instruction[(pwm << 1U) + 41U].Data = (((pwmPeriod * pwmDuty) / 100U) << 7U) + 128U;

}

 

 

In the last two lines, the PWM duty cycle is set using MOV64 instruction of HET.

The duty cycle is set to 0% and 100% using action=0(CLEAR) or action=2(SET) of MOV64 instruction.

 

When command duty cycle is 0%, The MOV64 instruction cannot switch PWM output high to low using action=2(SET).

Therefore I modify the code as follows to check action-field of the MOV64 instruction in HET-RAM and use action=3(PULSEHI) instead of action=2(SET) when command duty cycle is 0%.

 

 

   if (pwmDuty == 0U)

   {

       if ((uint32)(((hetRAM->Instruction[(pwm << 1U) + 41U].Control) & ((uint32)(0x00000018U))) >> 3U) == 2U)

           {

          action = pwmPolarity;

           }

       else

       {

           action = (pwmPolarity == 3U) ? 0U : 2U;

       }

   }

 

 

I checked the operation using TMS570LS0432 LaunchPAD and the PWM duty cycle switched from 100% to 0% correctly.

 

Is there a problem with the operation of the MCU using this workaround?

 

Please teach me if there are any other solution.

 

 

Thank you,