AnsweredAssumed Answered

MCO1 output doesn't output anything

Question asked by cherobim.marcio on Feb 21, 2013
Latest reply on Feb 26, 2013 by Moore.Patrick
Hello all,
Can someone help me please?

I must be doing something wrong because I can't do something so trivial...

I'm trying to output HSI over MCO1, it must be something straightforward, but...

void cpu_init_mco( void )
{
     GPIO_InitTypeDef GPIO_InitStructure;

     /* Output HSE clock on MCO1 pin(PA8) ****************************************/ 
     /* Enable the GPIOA peripheral */ 
     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);

     /* Configure MCO1 pin(PA8) in alternate function */
     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
     GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
     GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;  
     GPIO_Init(GPIOA, &GPIO_InitStructure);

     /* HSE clock selected to output on MCO1 pin(PA8)*/
     RCC_MCO1Config(RCC_MCO1Source_HSI, RCC_MCO1Div_5);
     GPIO_PinAFConfig( GPIOA, GPIO_PinSource8, GPIO_AF_MCO );
}

Yes, there is no secret, just setup the pin to alternate and enable MCO1, I call this method after everything is been initialized, but I also tried after clock was set (after SystemInit is called), I tried 50MHz, 100MHz, I tried MCO2, in case something is not right with MCO1, well, I tried everything but the right thing lol. I tried use different clocks, like PLL, I have another board with HSE, I tried it with RCC_MCO1Source_HSE and nothing, I tried debug going through step-by-step (using OpenOCD + STLink) - nothing, ok maybe in debug mode clock wont be there, so I put a while(1) to make execution stop in there, in case there is somewhere it's messing up with the pin - nothing. Tried without ST-Link, then as a desperate action tried other things like setting GPIO mode to output lol.

Apart this code snippet, is there anything else I need to do to have MCOx with clock? 

If anyone can help, that would be very appreciated!

Many Thanks,

Marcio.


EDIT: forgot to mention, I'm using STM32F407VGT6 (Mikroe) and STM32F405RGT6 (Cerb40). Thanks!

Outcomes