cancel
Showing results for 
Search instead for 
Did you mean: 

Run MCU at Full Speed

Vivek yadav1
Associate III

Hi.

I want to use my MCU at its max Speed.

I am using STM32F103C8T6( Blue Pill ).

Can any one Provide good resource?

can anyone Provide source code for this ?

Can anyone tell me about that in my Controller Why are we using RCC_CFGR and RCC_CFGR2?

What is the meaning of PLL, PLL2 and PLL3 and Differnece between them ?

1 ACCEPTED SOLUTION

Accepted Solutions
berendi
Principal

The best resource is chapter 7 of the reference manual, all RCC register are thoroughly explained.

STM32F103C8T6 has neither PLL2 nor PLL3, there are present on STM32F105/STM32F107 only.

View solution in original post

5 REPLIES 5
berendi
Principal

The best resource is chapter 7 of the reference manual, all RCC register are thoroughly explained.

STM32F103C8T6 has neither PLL2 nor PLL3, there are present on STM32F105/STM32F107 only.

Vivek yadav1
Associate III

Indeed reference manual is right source. but i am not that smart.

I write a code with my little knowledge. Can anyone examine my code.

void set_RCC_HSI_Clock_APB2_20MHz()
{
 
	// 1: #HSI oscillator clock / 2 selected as PLL input clock when PLL is disable
		RCC->CFGR |= HSI_DIV_2;
		// 2:
		RCC->CFGR |= PLLMULL_x_10;// setting PLL for 40 MHz
		// 3: APB2 presclaer AHB Div by 2 which means 40/2 = 20 MHz
		RCC->CFGR |= 1<<13;
 
 
		// 4: set HSI as clock
		RCC->CR  |= RCC_CR_HSION;
		// 5: wait for HSI to be ready
		while(!(RCC->CR & RCC_CR_HSIRDY));
 
 
		// 6: Enable PLL
		RCC->CR |= PLL_ON;
		// 7: check PLL ready Flag
		while(!(RCC->CR & PLL_RDY_FLAG ));
 
		// 8: select PLL as system Clock
		RCC->CFGR |= 0x00000002;
		// 9: wait for PLL to be ready
		while( !( RCC->CFGR & 0x00000008 ) );
 
		// 10: AHB preScaler div by 1
		RCC->CFGR |= 0x0 << 7;
}

Uwe Bonnes
Principal III

Compile your code with debug symbbols enables, step through this code and decode the RCC register values with the refenece manual. With some reasoning, you will find what is missing or what is wrong.

Otherwise, you can find a lot of bare-bones examles how to set 72 MHz on the net.

Thanks Uwe Bonnes

I have completed this task.

At that time I don't know about bare metal programming and I found it very difficult to understand. Now I love it.:beaming_face_with_smiling_eyes:

And when you see the performance and size of the code... :)

At least someone directed into right direction. The ultimate goal is to make your own high-level libraries which are implemented with register level code.