Closed embcla closed 2 years ago
Hi @embcla,
An instruction is missing in your code so that you can activate the CC2E. The code should then be:
MX_TIM2_Init();
if (HAL_TIM_Base_Start(&htim2) != HAL_OK) {
Error_Handler();
}
HAL_TIM_IC_Init(&htim2);
HAL_TIM_IC_Start_IT(&htim2, TIM_CHANNEL_1);
+ HAL_TIM_IC_Start_IT(&htim2, TIM_CHANNEL_2);
The HAL_TIM_IC_Start_IT(&htim2, TIM_CHANNEL_2)
function will starts the TIM Input Capture measurement in interrupt mode on the channel 2 and enables the TIM Capture Compare on the specified channel.
I hope this would help you.
With regards,
Hello @ASELSTM and thank you for taking a look at this.
The confusion comes from the fact that I couldn't find this mentioned anywhere. The STM32G0x1 RM0444 manual only mentions specific bits and registers, while the HAL has no example usage of groups of functions. Bridging that gap proved hard for me.
Hi @embcla,
It is mentioned in the HAL_TIM_IC_Start_IT() function description in the stm32g0xx_hal_tim.c driver.
Hence, as there is no issue please allow me then to close these thread. Thank you for your comprehension and thank you for your contribution.
With regards,
Caution The Issues are strictly limited for the reporting of problem encountered with the software provided in this project. For any other problem related to the STM32 product, the performance, the hardware characteristics and boards, the tools the environment in general, please post a topic in the ST Community/STM32 MCUs forum.
Describe the set-up
Describe the bug When TIM2 is configured as pwm input capture to capture both duty and frequency, and capturing is enabled, CC2E is not set resulting in failure to acquire the second register value.
How To Reproduce
Configure TIM2 with CubeMX on a STM32G071 like in the picture, pay attention to the fact that Channel1 is on rising edge, while Channel2 is on falling edge![image](https://user-images.githubusercontent.com/54371771/139463058-35fc062d-cb91-4a3c-9454-36f4836c1118.png)
in the code, call everything necessary to start the capture
CC2E won't be set, so only the rising edge interrupt will be generated
Solution is to add bit set operation after starting the capture
Timer2 setup code as generated by CubeMX