Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for PWM #29

Merged
merged 1 commit into from
Jan 10, 2022
Merged

Support for PWM #29

merged 1 commit into from
Jan 10, 2022

Conversation

mgottschlag
Copy link
Contributor

This PR adds support for PWM. I took the code from stm32h7xx-hal as the basis as it seemed to provide the most complete implementation for the various timers. The changes include:

  • stm32g4xx-hal uses a different API for clock gating/reset.
  • stm32g4 is missing many bit/field names, so the code often uses .bits()
    or .set_bit()/.clear_bit() instead.
  • The advanced-control timers of the STM32G4 MCUs provide four
    complementary outputs.

This PR requires a recent git version of stm32g4 as the last released version contains some wrong register sizes and types. Therefore, this PR cannot be merged as-is.

I tested a single PWM as shown in the example. The oscilloscope showed the correct duty cycle and period. I did not test advanced features such as deadtime insertion or complementary outputs. I will conduct a test with multiple PWM outputs later.

@luctius
Copy link
Collaborator

luctius commented Dec 13, 2021

A new version of the stm32g4 crate has been merged, does that resolve your problems regarding this PR?

This commit requires a recent git version of stm32g4 to compile, as the
last released version specifies some wrong register sizes and types.

The changes to the code include:
- stm32g4xx-hal uses a different API for clock gating/reset.
- stm32g4 is missing many bit/field names, so the code often uses .bits()
  or .set_bit()/.clear_bit() instead.
- The advanced-control timers of the STM32G4 MCUs provide four
  complementary outputs.
@mgottschlag
Copy link
Contributor Author

mgottschlag commented Dec 15, 2021

Yes, it does. This is probably ready to be reviewed.

@mgottschlag mgottschlag marked this pull request as ready for review December 15, 2021 21:21
@mgottschlag mgottschlag changed the title Draft: Support for PWM Support for PWM Dec 15, 2021
This was referenced Dec 16, 2021
@luctius luctius merged commit acd3247 into stm32-rs:master Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants