Skip to main content
Visitor II
September 17, 2024
Solved

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

  • September 17, 2024
  • 2 replies
  • 1974 views

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?

 

    This topic has been closed for replies.
    Best answer by KHarb.1

    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.

     

    2 replies

    Super User
    September 18, 2024

    > 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.

    KHarb.1Author
    Visitor II
    September 18, 2024

    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?

    Super User
    September 18, 2024

    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.

    Super User
    September 18, 2024

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