Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 11 months ago.
baud rate problem on Nucleo-F070RB platform
Hi,
I recently purchased a Nucleo-F070RB (MB1136 C-03) from DigiKey, and I have encountered a problem when running the Nucleo_printf example. The code and library documentation say that the default baud rate is 9600, but when I run the code the baud rate is actually 57600. It appears that the PLL is being initialized after the UART, so the UART code initializes BRR as if the system clock will be running at 8 MHz. The system clock is later bumped up to 48 MHz, so the baud rate is off by a factor of 6x.
Here's a gdb session that shows SetSysClock_PLL_HSE() being called after UART_SetConfig(). Note the order in which the breakpoints are encountered.
galens@lion:Nucleo_printf$ /opt/arm/gcc-arm-none-eabi-4_9-2015q1/bin/arm-none-eabi-gdb -q Nucleo_printf.elf Reading symbols from Nucleo_printf.elf...done. (gdb) target extended-remote localhost:3333 Remote debugging using localhost:3333 0x080016b4 in SetSysClock_PLL_HSE () (gdb) load Loading section .text, size 0x4f88 lma 0x8000000 Loading section .ARM.exidx, size 0x8 lma 0x8004f88 Loading section .data, size 0x84 lma 0x8004f90 Start address 0x8000830, load size 20500 Transfer rate: 20 KB/sec, 5125 bytes/write. (gdb) b SetSysClock_PLL_HSE Breakpoint 1 at 0x80016b4 (gdb) b UART_SetConfig Breakpoint 2 at 0x800136a (gdb) c Continuing. Note: automatically using hardware breakpoints for read-only addresses. Breakpoint 2, 0x0800136a in UART_SetConfig () (gdb) backtrace #0 0x0800136a in UART_SetConfig () #1 0x0800157e in HAL_UART_Init () #2 0x080017b0 in init_uart () #3 0x08001866 in serial_init () #4 0x08001c04 in mbed::SerialBase::SerialBase(PinName, PinName) () #5 0x08001b86 in mbed::Serial::Serial(PinName, PinName, char const*) () #6 0x08000284 in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at main.cpp:8 #7 _GLOBAL__sub_I_pc () at main.cpp:20 #8 0x0800290a in __libc_init_array () #9 0x08000862 in LoopFillZerobss () Backtrace stopped: previous frame identical to this frame (corrupt stack?) (gdb) c Continuing. Breakpoint 2, 0x0800136a in UART_SetConfig () (gdb) backtrace #0 0x0800136a in UART_SetConfig () #1 0x0800157e in HAL_UART_Init () #2 0x080017b0 in init_uart () #3 0x08001866 in serial_init () #4 0x08001c04 in mbed::SerialBase::SerialBase(PinName, PinName) () #5 0x08001b86 in mbed::Serial::Serial(PinName, PinName, char const*) () #6 0x08000284 in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at main.cpp:8 #7 _GLOBAL__sub_I_pc () at main.cpp:20 #8 0x0800290a in __libc_init_array () #9 0x0800016a in _start () Backtrace stopped: previous frame identical to this frame (corrupt stack?) (gdb) c Continuing. Breakpoint 1, 0x080016b4 in SetSysClock_PLL_HSE () (gdb) backtrace #0 0x080016b4 in SetSysClock_PLL_HSE () #1 0x08001758 in SetSysClock () #2 0x080004bc in mbed_sdk_init () #3 0x080007ca in __wrap_main () #4 0x08000172 in _start () Backtrace stopped: previous frame identical to this frame (corrupt stack?) (gdb)
I encountered the same baud rate problem when using the binary that I built using the mbed web-based IDE. Note that I am using mbed revision 109.
Am I doing something wrong, or is this a bug?
thanks,
galen
1 Answer
9 years, 11 months ago.
Try using an older version of the mbed lib, see: https://developer.mbed.org/questions/61386/Is-there-system-clock-error-in-STM32F030/
Thanks for the response. I narrowed the problem down to revision 108. Revision 107 works as expected. Can you tell me how to determine the mbed github hash that corresponds to a given mbed revision? If I had the github hash for 107 and 108, I could probably find the commit that caused the problem. That's assuming github is where the actual development is taking place. The whole mbed.org+mercurial / github.com+git development environment is rather confusing. I haven't found any web pages that describe how development takes place.
posted by 03 Nov 2015Well, thats because no one knows how it works exactly :P. Here you can see the revision history: https://github.com/mbedmicro/mbed/commits/master/libraries/mbed/api/mbed.h
So from that you can look at between which dates they broke it.
posted by 03 Nov 2015OK, so commit d571b16e907bd404dc5bbba7ae18ad79d5899b75 appears to have broken the default baud rate, probably for all F0 devices. Do you know the communication method preferred by the ST developers? Looks like I could post to Bugs & Suggestions or the ST forum, open an issue on mbed.org, or open an issue on github. So many options, so little guidance.
posted by 05 Nov 2015I would use github. I don't know about ST forum, I do know bugs and suggestions here is largely ignored, issues on mbed libraries opened here are pretty much completely ignored.
posted by 05 Nov 2015I just opened an issue on github. Thanks for your help. https://github.com/mbedmicro/mbed/issues/1419
BTW, I discovered the default SPI clock frequency is 1.5 MHz rather than the documented 1 MHz. Perhaps this is the best they can do given the limitations of the SPI prescaler.
posted by 11 Nov 2015