Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a function called
set_center_aligned_mode_selection()
to allowCMS
selection. Using center aligned mode reduces current harmonics when driving a motor, and allows predictable ADC sampling of motor current at TIM1 counter overflow.I tested it to be working on a STM32f401 MCU. I logged values in
TIM1_UP_TIM10
interrupt and saw the counter value in the CNT register to be alternating between 0 and 65521, indicating the counter is counting up and down. Since I don't have an oscilloscope, I hooked it up with an LED with 1 Hz PWM frequency, and changing the duty cycle between 50% and 10%. The time interval between the LED seem to be consistent, so I'm pretty sure it is working correctly. It would be great if someone can test this out with an actual oscilloscope though.P.s. This will work great with the already existing complementary channel and dead time features for driving and sensing BLDC motors.
Please let me know if this PR is acceptable, and I'd be happy to make any changes necessary to get this merged.
Thanks!