Change or initialize clock frequency?

Thread Starter

ApacheKid

Joined Jan 12, 2015
139
Hi,

I was wondering if it possible (or recommended practice) to set the CPU clock frequency programatically?

I'm working on an STM32F769I-DISC0 (that's a zero not a letter "O" by the way!) and it seems to run at 16MHz when powered up.

I can call HAL_RCC_GetHCLKFreq during my app's startup and see that it's 16,000,000.

I've no idea if one can adjust this or if one can "ask" the board what clock frequencies are supported/available or if I can then set it.

I've read a few articles on the web but most of these assume more expertise that I have!

Thanks
 

jpanhalt

Joined Jan 18, 2008
8,460
I use Microchip PIC devices. I suppose it is possible to reset the clock frequency. I have never tried to do that. But, I very often use a separate clock for Timer 1 (e.g., a 32.nnnn kHz timer clock). Why do you want to reset the master clock frequency? Do you really need to do that?
 

Thread Starter

ApacheKid

Joined Jan 12, 2015
139
I use Microchip PIC devices. I suppose it is possible to reset the clock frequency. I have never tried to do that. But, I very often use a separate clock for Timer 1 (e.g., a 32.nnnn kHz timer clock). Why do you want to reset the master clock frequency? Do you really need to do that?
Well the device has multiple possible clock sources and speeds, I'm not clear if this are dictated by the board's hardware or not.

The board (it seems) supports a possible 216 MHz clock yet appears to default to 16 MHz (lower clock is preferred for reduced power consumption).
 
Last edited:

nsaspook

Joined Aug 27, 2009
6,708
I would expect the high speed cpu clock is set by the PLL (usually there is a separate peripheral clock PLL) using a set of division factors with the internal or external clock as the base. You set the X PLL and enable it only once after the default or initial clock selection.
 

jpanhalt

Joined Jan 18, 2008
8,460
Well the device has multiple possible clock sources and speeds, I'm not clear if this are dictated by the board's hardware or not.
Probably not. Read the datasheet.

The board (it seems) supports a possible 216 MHz clock yet appears to default to 16 MHz (lower clock is preferred for reduced power consumption).
So?

You still haven't given a clue why you want to change the oscillator frequency.
 

Thread Starter

ApacheKid

Joined Jan 12, 2015
139
Did you buy a device without a datasheet? That's for you to answer. Perhaps one of the datasheets you reference in post #8 has the answer.
Buddy, if you don't know then say so. I'm reeling from a personal loss and absorbing myself in a former hobby/interest, I politely asked a presumably simple question (which may be obvious to your erudite self) so either answer it or leave me in peace please.
 
Last edited:

Thread Starter

ApacheKid

Joined Jan 12, 2015
139
The 'documentation' glibly referred to by some here, is extensive. I'm personally no stranger to such extensive explanatory material but the availability of such material does not mean that one cannot or should not ask questions. I've read over many documents and not yet found a definitive answer to my question.

For example this document is close to 2,000 pages (and there are many more) and despite scouring it the answer to my question eludes me.

I see no reason for forums like this if the advice one receives is simply RTFM, because almost every question one could ask, could be answered in that way.

So jpanhalt, if your contributions to this subject matter are nothing more than this then please confirm this and I'll gladly ignore you.
 

MrChips

Joined Oct 2, 2009
19,915
The system clock on all STM32 chips are initialized by code on start up. The IDE toolset, compiler and link have loaded code to set the internals for you.

The STM32F769I-DISCO uses an external 25MHz oscillator module and internally the CPU is running at over 200MHz.
 

Thread Starter

ApacheKid

Joined Jan 12, 2015
139
The system clock on all STM32 chips are initialized by code on start up. The IDE toolset, compiler and link have loaded code to set the internals for you.

The STM32F769I-DISCO uses an external 25MHz oscillator module and internally the CPU is running at over 200MHz.
Hmm, clearly there's more to this than I thought, I see under debug that my board is using a 16 MHz clock, I'll get to the bottom of this, good problem for me.

Many thanks Mr Chips.
 

MrChips

Joined Oct 2, 2009
19,915
16MHz is the internal RC clock called HSI. This is not the internal CPU clock. The CPU SYSCLK can be as high as 216MHz.
Here is the clock tree for STM32F769:

SMT32F7xx Clock Tree.jpg
 
Top