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.

TMS320F280049C: TMS320F280049 HRPWM 设置高分辨率周期和移相,频率无法实时被改变?

Part Number: TMS320F280049C


#define MIN_HRPWM_PRD_PERCENT   (20.0003f)
void changeHZ(double zTemp)
{
    uint32_t compCount = 0UL;
    double iTemp = 0.0f;
    uint32_t aTemp = 100000UL;
    uint32_t xTemp = 0UL;
    double  yTemp = 0.0f;

    iTemp = aTemp / zTemp;
    xTemp = floor(iTemp);  //取整数部分
    yTemp = iTemp - xTemp; //减,以取小数部分
    compCount=yTemp*256;
    EPwm1Regs.TBPRD =xTemp-1;
    EPwm1Regs.TBPRDHR = compCount<<8;

    EPwm3Regs.TBPRD =xTemp-1;
    EPwm3Regs.TBPRDHR = compCount<<8;
}

void main(void)
{

    //
    // Initialize device clock and peripherals
    //
    Device_init();

    //
    // Disable pin locks and enable internal pull ups.
    //
    Device_initGPIO();

    //
    // Initialize PIE and clear PIE registers. Disables CPU interrupts.
    //
    Interrupt_initModule();

    //
    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    //
    Interrupt_initVectorTable();

    //
    // Initialize EPWM GPIOs
    //
    PinMuxEPWM1_init();
    PinMuxEPWM3_init();
    EPWM1_init();
    EPWM3_init();

    //
    // Calling SFO() updates the HRMSTEP register with calibrated MEP_ScaleFactor.
    // HRMSTEP must be populated with a scale factor value prior to enabling
    // high resolution period control.
    //
    while(status == SFO_INCOMPLETE)
    {
        status = SFO();
        if(status == SFO_ERROR)
        {
            error();   // SFO function returns 2 if an error occurs & # of MEP
        }              // steps/coarse step exceeds maximum of 255.
    }



    //
    // Disable sync(Freeze clock to PWM as well)
    //
    SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);

    initHRPWM(EPWM_TIMER_TBPRD);

    //
    // Enable sync and clock to PWM
    //
    SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);

    //
    // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
    //
    EINT;
    ERTM;
    
    for(;;)
    {
         //
         // Sweep DutyFine
         //
         for(periodFine = MIN_HRPWM_PRD_PERCENT; periodFine < (MIN_HRPWM_PRD_PERCENT+0.005); periodFine += 0.0001)
         {//从20.0003kHZ开始加,每次加0.0001KHZ(也就是0.1HZ)
         
            //断点调试,示波器抓取频率,会正常改变:
            //延时低于800000us,示波器抓取频率,不是按照0.1HZ跳变 :
             DEVICE_DELAY_US(10);
             changeHZ(periodFine);
             //
             // 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.
         }
     }
}

1,配置PWM1+PWM3的HRPWM输出,PWM3对PWM1移相

2,从20.0003kHZ开始加,每次加0.0001KHZ(也就是0.1HZ)
3,断点调试,示波器抓取频率,会正常改变:
4,延时低于800000us,示波器抓取频率,不按0.1HZ跳变 :

请问这是何故?