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.
7 years, 8 months ago.
How to generate an RCC MCO clock out of the Nuclero board using mbed?
Hello,
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?
Thanks
Question relating to:
1 Answer
7 years, 8 months ago.
You should be able to call the low level HAL functions to activate MCO.
/* Output clock on MCO1 pin(PA8) for debugging purpose */ HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_SYSCLK, RCC_MCODIV_1); //HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI48, RCC_MCODIV_2);
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 02 Mar 2017Hmm, 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 */ HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI48, RCC_MCODIV_2);
That compiles for the L053. Check to see if that produces the 24 MHz clock.
posted by 02 Mar 2017