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.

TMS320F280049: HRPWM manual convert issue

Part Number: TMS320F280049
Other Parts Discussed in Thread: C2000WARE

Hi experts,

My customer use the manual convert mode. The wave seems strange as below:

If they change to auto-convert mode. The wave is right:

Please help review the codes. Thank you in advance!

for(;;)

    {

         //

         // Sweep DutyFine

         //

        fPWMperiod = PWM_CLOCK_FREQ/fPWMFreqtest/2.0f;/*1.5MHz*/

#if 1

         for(periodFine = MIN_HRPWM_PRD_PERCENT; periodFine < 0.9; periodFine += 0.01)

         {

             DEVICE_DELAY_US(1000);

 

             count = (((uint16_t)EPWM_TIMER_TBPRD) << 8UL) + (float32_t)(periodFine * 256);

             compCount = count;

             HRPWM_setTimeBasePeriod(ePWM[1], compCount);

 

             //

             // Call the scale factor optimizer lib function SFO()

             // periodically to track for any change due to temp/voltage.

             // This function generates MEP_ScaleFactor by running the

             // MEP calibration module in the HRPWM logic. This scale

             // factor can be used for all HRPWM channels. The SFO()

             // function also updates the HRMSTEP register with the

             // scale factor value.

             //

             status = SFO(); // in background, MEP calibration module

                             // continuously updates MEP_ScaleFactor

 

             if (status == SFO_ERROR)

             {

                 error();   // SFO function returns 2 if an error occurs & #

                            // of MEP steps/coarse step

             }              // exceeds maximum of 255.

         }

 

#else

         fPWMperiodFrac = fPWMperiod - (uint16_t)(fPWMperiod);

 

         //float32_t count = (((uint16_t)EPWM_TIMER_TBPRD-1) << 8UL) + (float32_t)(periodFine * 256);

         //uint32_t compCount = count;

         //HRPWM_setTimeBasePeriod(ePWM[1], compCount);

 

         count = (uint16_t)(fPWMperiodFrac*256*56+128)>>8;

 

         //count = 0;

         compCount = (((uint16_t)fPWMperiod) << 8UL) + count;

 

         HRPWM_setTimeBasePeriod(EPWM1_BASE, compCount);

 

         //EPwm1Regs.TBPRD = (uint16_t)(fPWMperiod);

         //EPwm1Regs.TBPRDHR = (uint16_t)count<<8;

 

         status = SFO(); // in background, MEP calibration module

                                     // continuously updates MEP_ScaleFactor

 

         if (status == SFO_ERROR)

         {

             error();   // SFO function returns 2 if an error occurs & #                                    // of MEP steps/coarse step

         }

#endif

 

     }