2 months, 3 weeks ago.

How to generate an RCC MCO clock out of the Nuclero board using mbed?


I am trying to generate a 24 MHz signal from the NUCLEO L053R8 board to use as a clock for another device. Can anyone give me any suggestions on how to do it on mbed?


Question relating to:

Affordable and flexible platform to ease prototyping using a STM32L053R8T6 microcontroller.
Comment on this question

1 Answer

2 months, 3 weeks ago.

You should be able to call the low level HAL functions to activate MCO.

/* Output clock on MCO1 pin(PA8) for debugging purpose */

This should get you a 32 MHz clock (same as the SystemCoreClock). However, you can modify the PLL settings to use a multiplier of 3 for the standard 8 MHz clock input to set the SystemCoreClock to 24 MHz. See Zoltans examples here.

An alternative solution could be to select HSI48 as MCO source and set the MCO divider at 2.

the problem when using Zlotans example is that I am getting errors because the values for the registers are undefined. Do I need to define all of them myself one by one ?

posted by Jonathan Camilleri 02 Mar 2017

Hmm, the SysClockConfig.cpp example code is for the F103 and the L053 has some differences in the clock setup so some of the register values for the F103 are not defined when you compile the code for the L053. The MCO part looks ok, but the PLL settings need to be checked. In case you want to go that way the easiest approach is to import the mbed source code for the L053 clock setup and then modify that along the way of Zoltan's example.

The existing HAL registers for the L053 should be accessible through "mbed.h''

So a quick solution is to remove the SysClockConfig.cpp example code and just add the line below to your main.

/* Output clock on MCO1 pin(PA8) for debugging purpose */

That compiles for the L053. Check to see if that produces the 24 MHz clock.

posted by Wim Huiskamp 02 Mar 2017

To post an answer, please log in.