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.
Part Number: LAUNCHXL-F28377S
Tool/software: Code Composer Studio
Hi,
I do not know which value is the right to write in the TBPRDHR Register. I have autoconversion enabled.
Lets assume the EPWMCLK=TBCLK is running with 100MHz. SYSCLK is running with 200MHz. And i want to create a PWM period of 100.05kHz.
Set the TBPRD Register value to 999 to get 100kHz.
For the TBPRDHR Register value i am not sure.
One coarse step is equivalent to 0.1kHz, so 0.05kHz would be the half. So do i write 65535/2 in the TBPRDHR Register???
Hi Jonas,
Have you looked at the hrpwm_prdupdown_sfo_v8 example in ControlSUITE? I think this will help clarify some things for you. Here is the applicable loop from the code:
// // Sweep PeriodFine as a Q16 number from 0.2 - 0.999 // for(PeriodFine = 0x3333; PeriodFine < 0xFFBF; PeriodFine++) { if(UpdateFine) { // // Because auto-conversion is enabled, the desired // fractional period must be written directly to the // TBPRDHR (or TBPRDHRM) register in Q16 format // (lower 8-bits are ignored) // // EPwm1Regs.TBPRDHR = PeriodFine; // // The hardware will automatically scale // the fractional period by the MEP_ScaleFactor // in the HRMSTEP register (which is updated // by the SFO calibration software). // // Hardware conversion: // MEP delay movement = ((TBPRDHR(15:0) >> 8) * HRMSTEP(7:0) + // 0x80) >> 8 // for(i=1; i<PWM_CH; i++) { (*ePWM[i]).TBPRDHR = PeriodFine; //In Q16 format } } else { // // No high-resolution movement on TBPRDHR. // for(i=1; i<PWM_CH; i++) { (*ePWM[i]).TBPRDHR = 0; } } // // Call the scale factor optimizer lib function SFO(0) // 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. HRMSTEP // register is automatically updated by the SFO function. // 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. } // end PeriodFine for loop