cancel
Showing results for 
Search instead for 
Did you mean: 

MCSDK6.3.2 GenerateCode Error about TIM8

ZHOUXIANG
Associate III

 I use MCSDK6.3.2 to generate code, when use TIM1 to generate pwm wave, everything is ok. But, when I use TIM8 to generate pwm wave, the code is still TIM1, which is fixed in the code, not according to the pwmc_handle. What is wrong?  Is this a bug?

ZHOUXIANG_0-1747788422129.png

ZHOUXIANG_1-1747788431802.png

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi ZHOUXIANG, sorry for this inconvenience of code generation. You pointed out a bug into the "pwmc_sixstep.c" file regarding this Timer number management. The functions should be the following:

Into the MCSDK 6.3.2

/**
* @brief It updates the stored duty cycle variable.
* @PAram pHandle Pointer on the target component instance.
* @PAram new duty cycle value.
* @retval none
*/
__weak void PWMC_SetPhaseVoltage( PWMC_Handle_t * pHandle, uint16_t DutyCycle )
{
pHandle->CntPh = DutyCycle;
LL_TIM_WriteReg(pHandle->pParams_str->TIMx, CCR1, (uint32_t) DutyCycle);
LL_TIM_WriteReg(pHandle->pParams_str->TIMx, CCR2, (uint32_t) DutyCycle);
LL_TIM_WriteReg(pHandle->pParams_str->TIMx, CCR3, (uint32_t) DutyCycle);
}

/**
* @brief This function disable the update of the demagnetization counter in the update event
* @PAram pHandle: handler of the current instance of the PWM component
* @retval none
*/
__weak void PWMC_DisableHighFreqTask( PWMC_Handle_t * pHandle )
{
LL_TIM_DisableIT_UPDATE(pHandle->pParams_str->TIMx);
}

into MCSDK 6.4.0:

/**
* @brief It updates the stored duty cycle variable.
* @PAram pHandle Pointer on the target component instance.
* @PAram new duty cycle value.
* @retval none
*/
__weak void PWMC_SetPhaseVoltage(PWMC_Handle_t *pHandle, uint16_t DutyCycle)
{
#ifdef NULL_PTR_CHECK_PWM_SIXSTEP
if (MC_NULL == pHandle)
{
/* Nothing to do. */
}
else
{
#endif
pHandle->CntPh = DutyCycle;
LL_TIM_WriteReg(pHandle->pParams_str->TIMx, CCR1, (uint32_t)DutyCycle);
LL_TIM_WriteReg(pHandle->pParams_str->TIMx, CCR2, (uint32_t)DutyCycle);
LL_TIM_WriteReg(pHandle->pParams_str->TIMx, CCR3, (uint32_t)DutyCycle);
#ifdef NULL_PTR_CHECK_PWM_SIXSTEP
}
#endif
}

 

Best Regards.

Fabrice

View solution in original post

4 REPLIES 4
Gael A
ST Employee

Hello ZHOUXIANG,

Could you please provide more information on your issue ? If you could send your stwb6 project file and your board description json for example, that would be nice. Also be aware that MCSDK 6.4.0 is now available and don't hesitate to download it.

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.

Hope this will help,
Gaël A.

Hi ZHOUXIANG, sorry for this inconvenience of code generation. You pointed out a bug into the "pwmc_sixstep.c" file regarding this Timer number management. The functions should be the following:

Into the MCSDK 6.3.2

/**
* @brief It updates the stored duty cycle variable.
* @PAram pHandle Pointer on the target component instance.
* @PAram new duty cycle value.
* @retval none
*/
__weak void PWMC_SetPhaseVoltage( PWMC_Handle_t * pHandle, uint16_t DutyCycle )
{
pHandle->CntPh = DutyCycle;
LL_TIM_WriteReg(pHandle->pParams_str->TIMx, CCR1, (uint32_t) DutyCycle);
LL_TIM_WriteReg(pHandle->pParams_str->TIMx, CCR2, (uint32_t) DutyCycle);
LL_TIM_WriteReg(pHandle->pParams_str->TIMx, CCR3, (uint32_t) DutyCycle);
}

/**
* @brief This function disable the update of the demagnetization counter in the update event
* @PAram pHandle: handler of the current instance of the PWM component
* @retval none
*/
__weak void PWMC_DisableHighFreqTask( PWMC_Handle_t * pHandle )
{
LL_TIM_DisableIT_UPDATE(pHandle->pParams_str->TIMx);
}

into MCSDK 6.4.0:

/**
* @brief It updates the stored duty cycle variable.
* @PAram pHandle Pointer on the target component instance.
* @PAram new duty cycle value.
* @retval none
*/
__weak void PWMC_SetPhaseVoltage(PWMC_Handle_t *pHandle, uint16_t DutyCycle)
{
#ifdef NULL_PTR_CHECK_PWM_SIXSTEP
if (MC_NULL == pHandle)
{
/* Nothing to do. */
}
else
{
#endif
pHandle->CntPh = DutyCycle;
LL_TIM_WriteReg(pHandle->pParams_str->TIMx, CCR1, (uint32_t)DutyCycle);
LL_TIM_WriteReg(pHandle->pParams_str->TIMx, CCR2, (uint32_t)DutyCycle);
LL_TIM_WriteReg(pHandle->pParams_str->TIMx, CCR3, (uint32_t)DutyCycle);
#ifdef NULL_PTR_CHECK_PWM_SIXSTEP
}
#endif
}

 

Best Regards.

Fabrice

Thanks for your confirm!

I have upload the files, thanks for your help!