-
Notifications
You must be signed in to change notification settings - Fork 3k
[STM32F3]: fix for uart baudrate. #2099
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
misaligned comment. Did you consider doing this as part of the HAL init mbed_sdk_init(), I assume this might be required for more than just UART.
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 am fixing this locally, will merge it manually
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 are tabs, please use spaces
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.
On Arm , or uARM :SystemInit is called after boot (SystemInit write SystemCoreClock and call HAL_Init), then __main is called, this will perform zero initialized of bss , recopy of initialized variable (this will change the value of SystemCoreClock), then _initio calls init_serial (which calls init_uart, init_uart works properly if SystemCoreClock is correctly sets)
Later before calling main , mbed_sdk_init is called, this will update again SystemCoreClock and do again HAL_Init) which will allow a correct usage of UART or other peripheral with HAL.
On GCC_ARM, as zero initialized of bss , recopy of initialized variable is done early after reset and before SystemInit, the value of SystemCoreClock remains un-changed after SystemInit, so with GCC_ARM no need to add this fix in init_uart or in mbed_sdk_init.
On IAR , SystemInit is called after boot (SystemInit write SystemCoreClock and call HAL_Init), then __iar_program_start, this calls __iar_data_init3 which does zero initialized of bss, recopy of initialized data (this will change the value of SystemCoreClock), then mbed_sdk_init is called (This will put the value of systemCoreClock to the correct value) and the init_uart is called at the 1st printf . On IAR the fix in init_uart is not needed.
=> The Init is different according to compilers , this leads to un-confortable fix on ARM and IAR, due the late zero initiliazed, or recopy of initialized data for ARM, IAR compiler.