cancel
Showing results for 
Search instead for 
Did you mean: 

How to use external clock with STM32L011

pgregson1
Associate III

I am trying to use an external 8MHz clock with the STM32L011. I generate the clock using the MCO output on a STM32Nucleo-L476 board, and connect it to a STM32Nucleo-L011 board on its PA0 pi (A0 on the Nucleo's CN4 connector). I used STM32CubeMX to generate the code for the L476 to generate the clock. The clock works fine, providing a very good 3.3 volt, 8 MHz square wave as seen on my 200 MHz oscilloscope.

The code for the Nucleo L011 was generated by STM32CubeMX as well. The clock configuration has the HSE clock selected to provide SYSCLK, and the MCO output has SYSCLK selected for output with a divider of 1.

The inner "while(1)" loop contains a simple bit toggle with a 1-second period. That works fine as long as the external clock is not connected or the L476 board is in RESET so that its MCO output is disabled. The output frequency on the L011 MCO pin is 2.102 MHz; presumably this is the LSI oscillator providing the clock.

However, when the external clock is present on the Nucleo L011, the bit toggle loop does not run. I see the 8 MHz external clock on the PA0 pin of the MPU chip, but the the toggling does not work and the L011 MCO output shows a ground level only.

I have confirmed this action many times with different software each time. I have read the examples, adapted some of them to test this, read the reference manual and read the data sheet. I am at my wit's end.

Can someone help, please? My project requires the two processors to be synchronized.

Best regards,

Peter

3 REPLIES 3

> The code for the Nucleo L011 was generated by STM32CubeMX as well

Okay so dump it and write your own.

JW

My board with the L011 isn't in yet, so can't speak to personal experience quite yet.

The CK_IN pin should be able to take an 8 MHz input, configuring in HSE BYPASS mode.

If your toggling code is not working perhaps check that you aren't stuck in the Error_Handler() function. I'd suggests flagging via some GPIO, LED, or ideally USART output if you end up there to die. You could also use a debugger to stop execution, and see where it is actually stuck.

  /* -2- Enable HSE Oscillator, select it as PLL source and finally activate the PLL */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; // External clock source, ie TCXO, etc

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pgregson1
Associate III

Hello Gentlemen,

I had multiple problems, the largest being persistent "finger trouble". I had mis-wired my prototyping environment with two wires misplaced. Further, in the interests of decreasing the emitted EMI, I had selected the "low" setting for the frequency response of the MCO pin on the slave processor. Since it is a rise-time limit, the resulting rise time was too long to resolve an 8 MHz output signal. Rather than show an attenuated and distorted waveform, it showed none at all. Most confusing.

I have It working now as expected.

Best regards,

Peter