You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2019/05/18 15:50:57 UTC
[GitHub] [mynewt-core] wnts opened a new issue #1829: Wrong SystemCoreClock
value in b-l072z-lrwan1 bsp
wnts opened a new issue #1829: Wrong SystemCoreClock value in b-l072z-lrwan1 bsp
URL: https://github.com/apache/mynewt-core/issues/1829
The bsp package for the b-l072z-lrwan1 board uses an incorrect value for the SystemCoreClock value. https://github.com/apache/mynewt-core/blob/a2f5fd1837c33fd088f66391ce047d82e495b901/hw/bsp/b-l072z-lrwan1/src/system_stm32l0xx.c#L126
The SystemCoreClock variable is used by the hal to set the baud rate:
https://github.com/apache/mynewt-core/blob/706dd77e95339d218a73f52b1422ddf03ea9058b/hw/mcu/stm/stm32_common/src/hal_uart.c#L477-L485
This causes UART communication to fail, resulting in framing errors. I believe the https://github.com/apache/mynewt-core/blob/a2f5fd1837c33fd088f66391ce047d82e495b901/hw/bsp/b-l072z-lrwan1/src/system_stm32l0xx.c file originates in the STM32CubeL0 firmware package that is made available by ST. The [newest version of the STM32CubeL0 ](https://my.st.com/content/my_st_com/en/products/embedded-software/mcu-mpu-embedded-software/stm32-embedded-software/stm32cube-mcu-mpu-packages/stm32cubel0.license=1558105043022.product=STM32CubeL0.version=1.11.0.html)package contains a template (STM32Cube_FW_L0_V1.11.2/Projects/STM32L073Z-EVAL/Templates/Src/system_stm32l0xx.c) for the system32_stm32l0xx.c file, containing:
` uint32_t SystemCoreClock = 2097152U; /* 32.768 kHz * 2^6 */`
The comment seems to be wrong though, but the value is consistent with the device's reference manual. From the [reference manual of the STM32L0x2 ](https://www.st.com/content/ccc/resource/technical/document/reference_manual/63/3c/c0/51/1c/fb/44/d4/DM00108281.pdf/files/DM00108281.pdf/jcr:content/translations/en.DM00108281.pdf)microcontroller (STM DocID025941 Rev 5), section 7.2.3, "MSI Clock", p. 178:
> The MSI clock signal is generated from an internal RC oscillator. Its frequency range can be adjusted by software by using the MSIRANGE[2:0] bits in the RCC_ICSCR register (see Section 7.3.2: Internal clock sources calibration register (RCC_ICSCR)). Seven frequency ranges are available: 65.536 kHz, 131.072 kHz, 262.144 kHz, 524.288 kHz, 1.048 MHz, **2.097 MHz (default value)** and 4.194 MHz. **The MSI clock is always used as system clock after restart from Reset** and wake-up from Standby. After wake-up from Stop mode, the MSI clock can be selected as system clock instead of HSI16 (or HSI16/4).
I tried the console application from the blinky tutorial with the correct SystemCoreClock value, and the UART no longer glitches or displays framing errors.
A final remark: it seems to me that the hw/bsp/b-l072z-lrwan1/src/system_stm32l0xx.c file should not be under the bsp package in the source tree, since it contains no board specific code, but MCU specific code. I believe it should be at hw/mcu/stm/stm32l0xx/
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services