cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G4 does not output clock signals on MCO pin \ Where is the alternate function mapping table?

KHarb.1
Senior II

I'm using CubeIDE and I have PG10 configured as MCO output and I see nothing. Usually when I see this, there is a HAL enable command I missed, but I don't think there is in this case.  

I've tried multiple clock sources and the pin stays at voltage high. I've checked on all the registers I know:

GPIOG

   MODER -> MODER10 = 0x2 (alternate function)

   AFRL = 0x0

   AFRH = 0x0

 

I suspect that having no alternate function set in AFR\L registers is what is not correctly set, but I don't see the mapping table mentioned in the reference manual:  "Refer to the “Alternate function mapping” table in the device datasheet for the detailed mapping of the alternate function I/O pins."

What should these registers be set to for MCO and where is the mapping table?

 

1 ACCEPTED SOLUTION

Accepted Solutions

PG10 is also the NRST pin. I was able to trace this behavior to the NRST_MODE bits in FLASH_OPTR. I changed them from 0x3 to 0x2 and the MCO output started working along with normal GPIO which I also found to be failing.

 

View solution in original post

6 REPLIES 6
TDK
Guru

> Refer to the “Alternate function mapping” table in the device datasheet for the detailed mapping of the alternate function I/O pins.

So did you? The datasheet is a separate document from the reference manual.

TDK_0-1726625250229.png

MCO is AF0, so 0 is correct in those registers.

Make sure output speed is very high.

If you feel a post has answered your question, please click "Accept as Solution".

Ahh...once again, datasheet and reference manual are different.  So, yes...AF0 is correct. 

The RCC register configuration all seemed correct.

If I'm not seeing MCO output, what else could I look at?

Configure it in CubeMX and see if it works. If it does, compare your register values against what it does instead. If it doesn't work, set pin up as a GPIO output and toggle it and verify on a scope that you're actually monitoring the pin and not something else.

If you feel a post has answered your question, please click "Accept as Solution".

PG10 is also the NRST pin. I was able to trace this behavior to the NRST_MODE bits in FLASH_OPTR. I changed them from 0x3 to 0x2 and the MCO output started working along with normal GPIO which I also found to be failing.

 

Check out 

WEAK void SystemClock_Config(void){}

there is a line for MCO, something like 

HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_4);

TDK
Guru

You should post your chip name in the title or opening post next time. Could have been solved much quicker.

If you feel a post has answered your question, please click "Accept as Solution".