-
Notifications
You must be signed in to change notification settings - Fork 1k
Add generic F410Rx pinout #880
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
Conversation
This pinout is formatted the same way as the Generic F401Rx, F411Rx and 446Rx pinouts, and is used with the STM32F410R8 and STM32F410RB chips
Requires #882 |
Is there any way we can re-run Travis now that #882 is merged? |
Yes, anyway, I will not merge this one as it is. |
This is no different than the other generic pinouts. First, it tries HSE. If no crystal/clock is detected, it will switch to HSI. This must be the most compatible option? |
I will also change for other generic. |
So would you accept the generic pinouts to use an HSE based clock/crystal of 25 MHz and automatically switch to HSI if not present? And wouldn't it be better to merge my pending PRs like they are at the moment, and fix all generic F4 variants in the same commit/PR afterwards? After all their clock config is pretty much identical. |
No it is too much support. Goal is to provide an unique working clock config for every case.
Why adding codes we know they will be removed. |
So for all users that would like to use HSE they will have to redefine void SystemClock_Config(void)
{
SetSysClock_PLL_HSE(1 /* no bypass */, 25 /* MHz */);
} This would actually be quite neat! |
Yes, at least value and config will be aligned as they will have also to define the proper
The main issue is that the |
Yes, but HSE_VALUE is just a constant that isn't directly used by SetSysClock_PLL_HSE(0 /* no bypass*/, HSE_VALUE /* default val */); |
@MCUdude |
OK. So basically it isn't that easy to just pick a random crystal and expect it to work by only tweaking the clock config function. Hear me out here:
If you want, I can submit a PR for this. |
Wait, how is this not a problem on the F407 DISCO board (which I do own)? This board has an external 8 MHz crystal, but the HSE_VALUE is not redefined anywhere. |
In that case the clock config is correct but I guess if you use some dedicated feature, this would not work as expected, example RTC using HSE. |
Got it. So like mentioned in my previous post, why not "standardize" on 25 MHz for all generic F4 targets, and let the user redefine HSE_VALUE if needed? |
Even if you redefine HSE_VALUE, it is need to redefine the |
Yes, but this is very trivial: RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000L; |
Yes in that case, this work for the requested SYSCLK but for some other freq no. |
I've just done a pretty deep dive into how the clocks are initialized to get timing correctly. I've used CubeMX's graphical window to figure out what all the clock config values might represent. Working on my Nucleo F410RB, I was only able to get accurate timing (delay() in this case) when using an 8 MHz external clock. The PLL settings didn't even matter, the LED was blinking way too fast when using a 25 MHz clock even though the PLL settings should result in a 100 MHz SYSCLK. It turned out that the HSE_VALUE isn't 25000000 by default (For F401, F410 and F411 at least), it is 8000000! I believe it gets its definition here: Arduino_Core_STM32/system/STM32F4xx/stm32f4xx_hal_conf_default.h Lines 97 to 99 in 0ff0a2a
And not from here: Arduino_Core_STM32/system/STM32F4xx/system_stm32f4xx.c Lines 67 to 69 in 4e1c225
So then, 8 MHz is actually the default HSE_VALUE for the F4 series. Is this a bug or a feature? |
But this was at least a great learning experience for me 😀. I now feel I understand more about how the whole clock configuration works. In the process, I found out that the clock settings for some of the other generic variants I've created aren't really ideal. When we figure out what the default HSE_VALUE is, then I can submit a PR where I clean up some of this. I suggest we stick with either 8 MHz (default value for practically all other STM32 families) or 25 MHz, and then pass -DHSE_VALUE=25000000UL as a build option for targets/boards that require a special HSE_VALUE, such as the F401 blackpill board. |
Right, header is used before the source, so yes it is 8MHz. Forgot this. The default is the one in the |
In my opinion, it is even better to first try to use an external clock/oscillator and fall back to HSI if not present. This will cover most cases. For known boards that use another crystal, it's just a matter of adding -DHSE_VALUE={someval} in boards.txt. If you refuse this, another option is to rewrite SystemClock_Config into this: WEAK void SystemClock_Config(void)
{
if (SetSysClock_PLL_HSI() == 0) {
Error_Handler();
}
} ... and let the user override it in the sketch, like so, if he/she wants to use an external clock/crystal: void SystemClock_Config(void)
{
if (SetSysClock_PLL_HSE(0) == 0) {
Error_Handler();
}
} |
Now the external clock/crystal doesn't have to be 8 MHz as long as HSE_VALUE is defined at compile time. Clock frequency is also adjusted from 84 to 100 MHz
10f7d6f
to
ba12ed1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the clock config let's try like this.
Anyway all other should be updated according to this.
FMP TWI is not supported by this core anyways
This pinout is formatted the same way as the Generic F401Rx, F411Rx and 446Rx pinouts, and is used with the STM32F410R8 and STM32F410RB chips
Note that currently, this pinout does not compile due to a bug somewhere in the core. More info in #878.