Conversation
902f3b6 to
bd0418c
Compare
salkinium
left a comment
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Actually, the /Q prescaler isn't set at all, so the USB probably runs at 100MHz or something completely wrong.
There was a problem hiding this comment.
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 😄
There was a problem hiding this comment.
I swapped the prescalers to align with the CubeMX solution, so the CPU now runs at 96MHz and the USB still at 48MHz.
134d399 to
9f5b415
Compare
| static constexpr uint32_t Timer10 = Apb2Timer; | ||
| static constexpr uint32_t Timer11 = Apb2Timer; | ||
|
|
||
| static constexpr uint32_t Usb = 48_MHz; |
There was a problem hiding this comment.
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;
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Something easy, to build up 'momentum of success' will also support my motivational chemistry to complete the old graphic related PRs.
6e47b9f to
7e0b471
Compare
7e0b471 to
009bb06
Compare

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.