cancel
Showing results for 
Search instead for 
Did you mean: 

STM32f072R stuck at 16mhz (RESOLVED)

Laxel.1
Associate II

HI i got a problèm on an stm32f0.after a reset the µC is at 8mhz but i'm only able to climb to 16mhz when i want to go to 48MHZ , did someone have idea of where does the problem come from.

the µc are not new because i work on protoboard and i cant change it.

void Setup_Init_Clocks()
{
 
	RCC_DeInit();
	RCC_HSICmd(ENABLE);
	RCC_PLLConfig(RCC_PLLSource_HSI,6);//with that pll mult i must have 48mhz?
	//RCC_PREDIV1Config(1);
	RCC_PLLCmd(ENABLE);
 
	//RCC_PREDIV1Config(1);
	RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
	//RCC_USARTCLKConfig();definir si utile
	RCC_ClocksTypeDef value;
	RCC_GetClocksFreq(&value);
 
}
int main(void) {
	Elevator_Data test_cab;
	Setup_Init_Clocks();
	F_Init_IO();
	F_InitTimers();
	u8_F_CrepINIT();
	F_InitUSART1();
	F_InputsRead(&test_cab);
	F_LedsWrite(&test_cab);

thanks by advance

1 ACCEPTED SOLUTION

Accepted Solutions

> i got a timer with a blinking led , whatever i do with the PLL multiplier i got the same result on the led

It may be the "library" automatically changing the values set in Timer's registers, as you change the system clock. Read out and check the RCC and the Timer registers' content for the different versions.

> and how do you change the flash latency?

0693W00000LyR7cQAF.png0693W00000LyR9JQAV.pngJW

View solution in original post

5 REPLIES 5

> but i'm only able to climb to 16mhz

What is this, SPL?

What is "climb"? What happens if you "climb" higher? How do you verify the system clock?

Are you or the "libraries" you are using aware of the fact that you have to change FLASH latency setting (set waitstates), if you want to go beyond certain system clock frequency?

JW

I'm french so i'm trying to be the more clear as possible ,

i use the stdperiph given by ST,

i got a timer with a blinking led , whatever i do with the PLL multiplier i got the same result on the led

and how do you change the flash latency?

is that this ?0693W00000LyQjVQAV.png

> i got a timer with a blinking led , whatever i do with the PLL multiplier i got the same result on the led

It may be the "library" automatically changing the values set in Timer's registers, as you change the system clock. Read out and check the RCC and the Timer registers' content for the different versions.

> and how do you change the flash latency?

0693W00000LyR7cQAF.png0693W00000LyR9JQAV.pngJW

I finaly succeed to set a 48Mhz clock but now the code seem work only in debug is latency can cause that problème?

i'm trying to change the latency to see if it work

OK i finaly found how to set the latency and that seem like to work

thank you for your help waclawek.jan  ,have a nice day !

i post the code if someone need the solution :

void Setup_Init_Clocks()
{
	FLASH->ACR = 1;
	if ((RCC->CFGR & RCC_CFGR_SWS) == RCC_CFGR_SWS_PLL) /* (1) */
	{
	 RCC->CFGR &= (uint32_t) (~RCC_CFGR_SW); /* (2) */
	 while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_HSI) /* (3) */
	 {
	 /* For robust implementation, add here time-out management */
	 }
	}
	RCC->CR &= (uint32_t)(~RCC_CR_PLLON);/* (4) */
	while((RCC->CR & RCC_CR_PLLRDY) != 0) /* (5) */
	{
	 /* For robust implementation, add here time-out management */
	}
	RCC->CFGR = ((RCC->CFGR) & (~RCC_CFGR_PLLMUL)) | (RCC_CFGR_PLLMUL12); /* (6) */
	RCC->CR |= RCC_CR_PLLON; /* (7) */
	while((RCC->CR & RCC_CR_PLLRDY) == 0) /* (8) */
	{
	 /* For robust implementation, add here time-out management */
	}
	RCC->CFGR |= (uint32_t) (RCC_CFGR_SW_PLL); /* (9) */
	while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL) /* (10) */
	{
	 /* For robust implementation, add here time-out management */
	}
 
	RCC_ClocksTypeDef value;
	RCC_GetClocksFreq(&value);
}