2024-11-08 06:42 AM - last edited on 2024-11-08 07:04 AM by SofLit
Hello there. I am working on STM32G030 based FW. It appeared the TIM1x_CH1N doesn't work. I found out this part of code doesn't initialize negative channel(stm32g0xx_hal_tim.c).
Moreover it may skip all channels configurations. It seems to be a hard coded part that initializes only positive channel with defined CxP and CxN options if so it really skip user predefined ones.
Could you fix this issue and update HAL driver sources?
Thank you in advice.
2024-11-08 07:09 AM
Hello @MaxEE and welcome to the community,
@MaxEE wrote:
I found out this part of code doesn't initialize negative channel(stm32g0xx_hal_tim.c).
What do you mean by doesn't initialize negative channel? could you please elaborate?
@MaxEE wrote:
Moreover it may skip all channels configurations. It seems to be a hard coded part that initializes only positive channel with defined CxP and CxN options if so it really skip user predefined ones.
Could you fix this issue and update HAL driver sources?
The second part of your question is more related to CubeMx. What do you mean by hardcoded? in HAL? or option fixed in CubeMx?
2024-11-08 07:46 AM - edited 2024-11-08 07:49 AM
Whatever the configuration are TIM16_CH1N doesn't works. It always put 0x1 to CCER register yet if I set TIM16_CH1N only as an output there should be 0x4 or 0xC. I suppose it happens since TIM_CCx_ENABLE equals 0x1 which is used in hal driver function("TIM_CCxChannelCmd" run from "HAL_TIM_PWM_Start" function).
Here comes the second question, Why doesn't built-in device configuration tools change TIM_CCx_ENABLE according to the user configurations or there should be another way to set CCER register including user configuration in the hal driver. And as a result TIM16_CH1 is always on and TIM16_CH1N is always off.
So I requested to update hal driver sources to solve this issue.
2024-11-08 08:03 AM - edited 2024-11-08 08:06 AM
It seems to be 0x4 according to my configuration(maybe 0xc it depends on "OC1N active high" meaning that is specified in the spec).
It should've set right combination inside the driver like (TIM_CCx_ENABLE | TIM_CCxN_ENABLE).
2024-11-12 07:31 AM
Hello @MaxEE,
Although I'm not fully sure I grasped the issue, what I understood is that TIM_CCxChannelCmd is not taking into consideration TIM_CCxN_ENABLE, so when calling HAL_TIM_PWM_Start, it only starts the positive channel -Correct me if I'm mistaken
However, I would like to draw your attention to the HAL_TIMEx_PWMN_Start macro, which starts the PWM generation on the complementary output, it indeed uses TIM_CCxN_ENABLE to enable the complementary PWM output.
TIM_CCxNChannelCmd(htim->Instance, Channel, TIM_CCxN_ENABLE);
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.