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 disco_f411ve #1135

Merged
merged 1 commit into from
Mar 6, 2024
Merged

Add disco_f411ve #1135

merged 1 commit into from
Mar 6, 2024

Conversation

TomSaw
Copy link
Contributor

@TomSaw TomSaw commented Feb 26, 2024

Quite an old board i found behind the fridge. Very similar to disco_f407vg despite different clocks and PLL factors.

It's the only board in the modm collection featuring a stm32f411vet6, hence the clock and PLL constants maybe worth being stored.

@TomSaw TomSaw force-pushed the board/disco_f411ve branch 2 times, most recently from 902f3b6 to bd0418c Compare February 26, 2024 18:28
Copy link
Member

@salkinium salkinium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Do you want to try the USB example on this one? Should be almost identical to the F407 disco.

static constexpr uint32_t Timer10 = Apb2Timer;
static constexpr uint32_t Timer11 = Apb2Timer;

static constexpr uint32_t Usb = 48_MHz;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct?

Copy link
Contributor Author

@TomSaw TomSaw Mar 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've setup a PWM on Timer10 and Timer11, confirmed the output frequency and looks fine.

But could not make USB / TinyUSB working.
Please give me some advice!

Observations:

  • Power on without Usb-Cable, Leds blink period = 2.5s -> Seems to be the initial default
  • Connecting an Usb-Cable, the Leds blink period remains at 2.5s -> tud_mount_cb() not invoked.
  • However, when disconnecting the Usb-Cable, the blink period changes to 250ms -> tud_umount_cb() invoked!
  • Reconnecting the cable again, changes nothing. The blink period remains at 250ms.
  • Only a reset gets me back to 2.5s right now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's cos the USB is running at 50MHz and not 48MHz, hence my question about whether this clock is correct ;-P It probably works for a short time, but then gets out of sync.

CubeMX shows this solution running the CPU at 96MHz and USB at 48MHz:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the /Q prescaler isn't set at all, so the USB probably runs at 100MHz or something completely wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, i have not really tried to iunderstand the clock system yet. So i got a copy of CubeMX as it looks like an usefull reference. Have seen this graphical configurator before but your screenshot finally convinced me to give it a closer look, thanks!

USB now works 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I swapped the prescalers to align with the CubeMX solution, so the CPU now runs at 96MHz and the USB still at 48MHz.

@salkinium salkinium added this to the 2024q1 milestone Mar 1, 2024
@TomSaw TomSaw force-pushed the board/disco_f411ve branch 2 times, most recently from 134d399 to 9f5b415 Compare March 5, 2024 11:49
static constexpr uint32_t Timer10 = Apb2Timer;
static constexpr uint32_t Timer11 = Apb2Timer;

static constexpr uint32_t Usb = 48_MHz;
Copy link
Contributor Author

@TomSaw TomSaw Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PLL statements in all board.hpp could be moved above the SystemClock struct to calculate
SystemClock::Frequency and SystemClock::Usb

👉🏾 This would document the causality and the "...Usb requires 48Mhz..." assertion somewhere else in modm would have catched me!

Something like this:

static constexpr uint32_t CrystalHSE = 8;
const Rcc::PllFactors pllFactors {
   ...
}

static constexpr uint32_t MainPllClock = CrystalHSE / PllFactors.pllM * PllFactors.pllN;

static constexpr uint32_t SystemClock::Frequency = MainPllClock / PllFactors.pllP;
static constexpr uint32_t SystemClock::Usb = MainPllClock / PllFactors.pllQ;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhhhhhh, that's an excellent idea!!! I'll merge this first, then prototype it. We can probably also put the AHB/APB prescalers in there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something easy, to build up 'momentum of success' will also support my motivational chemistry to complete the old graphic related PRs.

Copy link
Contributor Author

@TomSaw TomSaw Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've quickly sketched this in #1137

@TomSaw TomSaw force-pushed the board/disco_f411ve branch 4 times, most recently from 6e47b9f to 7e0b471 Compare March 5, 2024 20:49
@salkinium salkinium merged commit 009bb06 into modm-io:develop Mar 6, 2024
12 checks passed
@TomSaw TomSaw deleted the board/disco_f411ve branch March 7, 2024 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants