MCSDK6.3.2 GenerateCode Error about TIM8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-19 3:41 AM - edited ‎2025-05-20 5:47 PM
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?
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-22 9:00 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-22 6:29 AM
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.
Hope this will help,
Gaël A.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-22 9:00 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-22 5:53 PM
Thanks for your confirm!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-22 7:09 PM
