Skip to content

Option to use HSE/LSI #5056

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
wants to merge 3 commits into from
Closed

Option to use HSE/LSI #5056

wants to merge 3 commits into from

Conversation

seemefirst
Copy link
Contributor

Added option to use external high speed crystal. To use the HSE/LSI a preprocessor must be defined in stm32l4xx_hal_conf.h as USE_HSE_LSI (1).

Added option use HSE and LSI.  To use the HSE/LSI a USE_HSE_LSI (1) must be defined in stm32l4xx_hal_conf.h.
@chrismas9
Copy link
Contributor

This is a useful improvement as it allows for accurate timers better than 0.25%. However it is reasonable to want HSE and LSE for accurate timers and RTC. I think selection of HSx and LSx should be separate, like F4. For example PYB has HSE and LSE, but on PYBLITE the 32 kHz crystal is optional . For consistency I suggest you use the macro name MICROPY_HW_CLK_USE_HSE and the existing MICROPY_HW_RTC_USE_LSE.

The PLL values should be defined in mpconfigboard.h, not in system_stm32.c, as some L4 run at 120 MHz, some applications run at less than 80 MHz to save power and some boards use a different crystal frequency. All the PLLSAI1 settings should use macros in mpconfigboard.h as the USB clock divider needs to be set to suit the crystal frequency.

When you make changes to a PR before it is reviewed you can squash the commits and force push.

Added option to use HSE or MSI clock
Adjusted option to use HSE or HSI clock for RTC for STML4

Uses definition in mpconfigboard.h

clock use:

MICROPY_HW_RTC_USE_LSE  1 or 0
MICROPY_HW_CLK_USE_HSE  1 or 0

PLLSAI1 N,P,Q,R settings

define MICROPY_HW_CLK_PLLSAIN (12)
define MICROPY_HW_CLK_PLLSAIP (RCC_PLLP_DIV7)
define MICROPY_HW_CLK_PLLSAIQ (RCC_PLLQ_DIV2)
define MICROPY_HW_CLK_PLLSAIR (RCC_PLLR_DIV2)
@chrismas9
Copy link
Contributor

@seemefirst Looks good. Thanks for making the changes.

@dpgeorge
Copy link
Member

dpgeorge commented Oct 4, 2019

Thanks for the contribution, merged in 266146a, with follow-up in 26e90a0

@dpgeorge dpgeorge closed this Oct 4, 2019
cdwilson pushed a commit to cdwilson/micropython that referenced this pull request Jul 26, 2021
…hon/fix-feather-stm32f405-express-can-pins

Fix CAN pin assignment on Feather STM32F405 Express board.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants