Are there any known issues with timer configuration in CubeMX for the STM32F407VG?
@Middleware & OS I'm developing a low-level PID controller for motor speed control on an STM32F407VG microcontroller. I'm using the STM32CubeMX tool to generate the initial project setup. However, I'm encountering issues during timer initialization for the motor speed measurement.
When I try to configure Timer 2 in CubeMX for capture mode, I get an error message stating
I've reviewed the STM32F4 reference manual and ensured the OPM bit is set to 0 (disabled) in the TIMx_CR1 register. However, the error persists. I'm using STM32CubeMX version 6.1.0.
Can anyone advise on how to resolve this specific error and configure Timer 2 for capture mode for motor speed measurement on the STM32F407VG?
Are there any known issues with timer configuration in CubeMX for this specific microcontroller?
Here's a relevant snippet of my CubeMX timer configuration:
Clock Source:
Internal Clock (APB1 clock)
Prescaler: 0
Auto-reload: 65535 (maximum count)
One Pulse Mode (OPM): Disabled (cleared in TIMx_CR1)
Update Event Source (URS): Update generation on counter overflow/underflow (selected in CubeMX)
Solution:Jump to solution
@UC GEE the issue with using the HAL is that its super easy to get started, however, when one does eventually get stuck its quite hard to get unstuck, since you need to debug the HAL and your code.
9 Replies
I have some code for input capture I however don't use the HAL
You can see my input capture solution here, https://github.com/zacck/general_timers/commit/023de2acc06999bf42b7497d2f7716b2a75316fe
GitHub
Implement Input Capture example · zacck/general_timers@023de2a
- Add Timer 2 in input capture mode
- Try to expose LSE but its missing
- Expose HSI to MC01 for testing input capture
Solution
@UC GEE the issue with using the HAL is that its super easy to get started, however, when one does eventually get stuck its quite hard to get unstuck, since you need to debug the HAL and your code.
Ok.. Thanks @ZacckOsiemo
Please @ZacckOsiemo What modifications are required for HAL, assuming one is left with "HAL" as the only option for the coding?
Thats a hard place to be in, I mean you could still implement it baremetal but just not use the HAL for this particular feature. Or you could debug the HAL
Yh true
Ok @ZacckOsiemo 👍
Try and implement it outside of the HAL, you should have CMSIS and it is less than 20 lines of code