cancel
Showing results for 
Search instead for 
Did you mean: 

LSE and HSE on MCO1

MehranMsba
Associate II
Posted on March 26, 2015 at 09:56

I use STM32F4

I set MCO1 to PLL Clock and set output prescaler to 5 and I have 6MHz on my MCO1. There is no problem in it, But when I enable LSE with HSE together, I have no signal on MCO1 pin. Code:

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 25;
RCC_OscInitStruct.PLL.PLLN = 336;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 7;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
HAL_RCC_MCOConfig(RCC_MCO1,RCC_MCO1SOURCE_PLLCLK,RCC_MCODIV_5);

What is the problem? Thanks...
4 REPLIES 4
Posted on March 26, 2015 at 13:38

Does some other unshown code configure the other GPIOs and clocks to allow this to work?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
MehranMsba
Associate II
Posted on March 26, 2015 at 14:59

Yes. GPIO configured with this code :

__GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF0_MCO;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

When I change this line:

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE;

to

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;

MCO1 clock is good and with LSE, I have no clock on MCO1 pin.
Posted on March 26, 2015 at 22:35

Try to blink a LED in the main loop, first with the setting where you do have the output clock, then with the other setting.

Does it blink in both cases?

JW

MehranMsba
Associate II
Posted on March 27, 2015 at 13:33

Yes.

I have LED blinking every 500mS in both cases(cmsis_os delay) 

and I have 1KHz signal of TIM3 too.

-----------------

In my new tests I have MCO1 clock in both cases!

(No board changes and no software changes!)

I am continuing my work and if this state happened again I will write state to this thread.

Thanks.