Skip to main content
Ted Jackson
Senior
Solved

In STM32CubeIDE, how does one determine the 'Core Clock' and 'SWO Clock' rate in the Debug Configuration for a working project from source and no IOC file?

..

This topic has been closed for replies.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru

 printf("\n\nCore=%d, %d MHz\n", SystemCoreClock, SystemCoreClock / 1000000);

The SWO side clock is usually determined by the debugger side interface, ie 2 MHz or whatever, and it then programs the chip side SWO baud rate and encoding scheme to relate the two. ie divisor = (168000000 / 2000000) - 1

The H7 side code looked like this

//SWO current output divisor register

//This divisor value (0x000000C7) corresponds to 400Mhz

//To change it, you can use the following rule

// value = (CPU Freq/sw speed )-1

*(__IO uint32_t*)(0x5C003010) = ((SystemCoreClock / 2000000) - 1); // SWO_CODR

Other systems

TPI->ACPR = ((SystemCoreClock / 2000000) - 1); /* "Async Clock Prescaler Register". Scale the baud rate of the asynchronous output */

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..

5 replies

Tesla DeLorean
Guru

You look at the clock and PLL settings

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Ted Jackson
Senior

I see no mention of Core Clock or SWO Clock in SystemClock_Config() or in a typical Clock Configuration page in CubeMX. Is there no utility to just measure that resultant clock rate? Can you be more specific please?

Tesla DeLorean
Tesla DeLoreanBest answer
Guru

 printf("\n\nCore=%d, %d MHz\n", SystemCoreClock, SystemCoreClock / 1000000);

The SWO side clock is usually determined by the debugger side interface, ie 2 MHz or whatever, and it then programs the chip side SWO baud rate and encoding scheme to relate the two. ie divisor = (168000000 / 2000000) - 1

The H7 side code looked like this

//SWO current output divisor register

//This divisor value (0x000000C7) corresponds to 400Mhz

//To change it, you can use the following rule

// value = (CPU Freq/sw speed )-1

*(__IO uint32_t*)(0x5C003010) = ((SystemCoreClock / 2000000) - 1); // SWO_CODR

Other systems

TPI->ACPR = ((SystemCoreClock / 2000000) - 1); /* "Async Clock Prescaler Register". Scale the baud rate of the asynchronous output */

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..