-
Notifications
You must be signed in to change notification settings - Fork 143
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 nucleo_f746zg board #396
Conversation
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.
Thanks for your first contribution to modm.
Just some minor polish required!
You'll also need remove the trailing whitespace and sync the docs or the CI will complain again: python3 tools/scripts/synchronize_docs.py then squash all of that into one commit. |
Oh, and you should add your example to the CI: |
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.
Clock configuration seems to be wrong.
static bool inline | ||
enable() | ||
{ | ||
Rcc::enableExternalClock(); // 25 MHz |
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.
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.
The external oscillator frequency always depends on the board, in the case the Nucleo linked above.
.pllM = 25, // 25MHz / M=25 -> 1MHz | ||
.pllN = 432, // 1MHz * N=432 -> 432MHz | ||
.pllP = 2 // 432MHz / P=2 -> 216MHz = F_cpu |
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.
// APB1 is running only at 27MHz, since AHB / 4 = 54MHz > 45MHz limit! | ||
Rcc::setApb1Prescaler(Rcc::Apb1Prescaler::Div8); | ||
// APB2 is running only at 54MHz, since AHB / 2 = 108MHz > 90MHz limit! | ||
Rcc::setApb2Prescaler(Rcc::Apb2Prescaler::Div4); |
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.
See above.
static constexpr uint32_t Apb1 = Frequency / 8; | ||
static constexpr uint32_t Apb2 = Frequency / 4; |
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.
See above.
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.
I understand that the settings are wrong. I am very sorry. So the input clock is 8Mhz. But I have no clue, how Apb1/2 have to be set. I would appreciate a hint very much.
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.
No problem.
I will add a suggestion of changes (with explanations) later.
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.
How to create the SystemClock
struct
The easies way using STs CubeMX tool.
1. CubeMX clock graph
First we create a project in CubeMX with the desired microcontroller using the largest (pin-count, flash) variant.
CubeMX will display something like this in the "Clock configuration" tab:
Than configure all the clocks, muxes, multipliers and dividers to the highest allowed clock speeds (*).
(*) Some exceptions: USB mostly needs exactly 48 MHz, tbc...
This settings are reflected in the static constexpr uint32_t Frequency
, Apb1
and Apb2
constants and in const Rcc::PllFactors pllFactors{...}
and the following lines.
The PllFactors
struct should be pretty self-explanatory.
2. Peripheral mapping to clocks
As we can see in the graphic above, there are different clock domains. Each peripheral is connected to a clock domain.
Some peripherals have an upstream clock mux, this is currently ignored in modm and the default clock mux setting is assumed.
The mapping is shown is the controllers block diagram located at the begin of the datasheet (not in the reference manual).
For every peripheral we create a static constexpr uint32_t
member in the struct SystemClock
and assign the value of the clock domain the peripheral is connected to.
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.
I pushed a some commits to your fork.
static constexpr uint32_t Apb1 = Frequency / 8; | ||
static constexpr uint32_t Apb2 = Frequency / 4; |
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.
How to create the SystemClock
struct
The easies way using STs CubeMX tool.
1. CubeMX clock graph
First we create a project in CubeMX with the desired microcontroller using the largest (pin-count, flash) variant.
CubeMX will display something like this in the "Clock configuration" tab:
Than configure all the clocks, muxes, multipliers and dividers to the highest allowed clock speeds (*).
(*) Some exceptions: USB mostly needs exactly 48 MHz, tbc...
This settings are reflected in the static constexpr uint32_t Frequency
, Apb1
and Apb2
constants and in const Rcc::PllFactors pllFactors{...}
and the following lines.
The PllFactors
struct should be pretty self-explanatory.
2. Peripheral mapping to clocks
As we can see in the graphic above, there are different clock domains. Each peripheral is connected to a clock domain.
Some peripherals have an upstream clock mux, this is currently ignored in modm and the default clock mux setting is assumed.
The mapping is shown is the controllers block diagram located at the begin of the datasheet (not in the reference manual).
For every peripheral we create a static constexpr uint32_t
member in the struct SystemClock
and assign the value of the clock domain the peripheral is connected to.
static bool inline | ||
enable() | ||
{ | ||
Rcc::enableExternalClock(); // 25 MHz |
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.
The external oscillator frequency always depends on the board, in the case the Nucleo linked above.
docs/src/guide/installation.md
Outdated
It may be that the linux' version of openocd is out of date. In this case install it | ||
directly from the [openocd][openocd] home page. | ||
|
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.
It may be that the linux' version of openocd is out of date. In this case install it | |
directly from the [openocd][openocd] home page. | |
The latest openocd release _0.10.0_ (as of May 2020) is too old for some targets (e.g. _STM32G0_, _STM32G4_). | |
In this case it might be necessary to compile openocd from git _HEAD_. |
How good are you with git and how much motivation do you have to cleaning up your PR history @FelixPetriconi (squashing and rebasing onto develop)? Otherwise I can just quickly do it, if you're ok with that. |
@FelixPetriconi Is it possible for you to test if my changes to the SystemClock struct work? |
I have never done it, because we are working in a regulated environment (medical devices) and for us are changes in the history forbidden. I looked into the git docs and I probably would figure out how to do it. But You are probably faster and the risk is lower, that bad things happens ;-). So could you do this please. But first I would like to test the changes tomorrow on the board. |
@salkinium What about using Githubs Squash-Merge Feature? |
I will do it tomorrow and report to you. My day is already too long to do something useful. But many thanks for the explanation. |
I just run test blink test program and while uploading I receive the following messages:
The program works and pressing the button has the effect - as expected - that the blinking is faster. |
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.
Rebased/squashed your commits and polished the install instructions.
Thanks, @FelixPetriconi! |
Improve slightly the docs