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

Add support for stm32l4r5 #292

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Add support for stm32l4r5 #292

wants to merge 6 commits into from

Conversation

gauteh
Copy link
Contributor

@gauteh gauteh commented Feb 26, 2022

Add support for stm32l4r5, requires: stm32-rs/stm32-rs#703

Based on #270 , also adds support for ADC1 which might be useful for r9. Not much tested yet.

@gauteh gauteh marked this pull request as ready for review February 27, 2022 09:03
@gauteh
Copy link
Contributor Author

gauteh commented Feb 27, 2022

Test repository: https://github.com/gauteh/swan-stm32l4r5-quickstart

Flashes and runs fine with probe-run.

@gauteh
Copy link
Contributor Author

gauteh commented Feb 27, 2022

Blinking is working, but I couldn't get the clock to work with 8Mhz: https://github.com/gauteh/swan-stm32l4r5-quickstart/blob/main/src/main.rs#L26, blinking and printing happily with the other clock though. Maybe @jspngh has an idea about whether this is supposed to work on r5 or r9?

@gauteh
Copy link
Contributor Author

gauteh commented Feb 27, 2022

Think I understand. Default configuration the sysclk is 4MHz, so 4 / 8 becomes 0. I think this assert: https://github.com/stm32-rs/stm32l4xx-hal/blob/master/src/rcc.rs#L635 should be raised to 120Mhz. Would be interesting to see if we could make the 0 verified at compile time and not a runtime error.

@jspngh
Copy link
Contributor

jspngh commented Feb 27, 2022

I can't immediately explain what's going wrong. If you have the option to step through the freeze method with gdb, it usually explains a lot of things.
For reference, here's how I configure the clocks (but with an external crystal). Being more explicit about what I wanted solved an issue in my case.

        let clocks = rcc
            .cfgr
            .hse(
                24.MHz(),
                CrystalBypass::Disable,
                ClockSecuritySystem::Disable,
            )
            .pll_source(hal::rcc::PllSource::HSE)
            .sysclk_with_pll(80.MHz(), PllConfig::new(3, 20, PllDivider::Div2))
            .pclk1(40.MHz())
            .pclk2(40.MHz())
            .freeze(&mut flash.acr, &mut pwr);

@gauteh
Copy link
Contributor Author

gauteh commented Feb 27, 2022

Thanks, I am unfamiliar with the way of configuring the clocks. Seems like there are several roads to the same goal.

@ant32
Copy link

ant32 commented Mar 18, 2022

I'm excited for this! I got the example working on a NUCLEO-L4R5ZI that I have. I'm hoping to get USB serial working.

add stm32l4r5 to otg_fs feature list
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.

3 participants