So you have got an STM32F4 discovery board in your hands. I can surely assume one of the reason you got this nifty little development board is it's computing capability at 168MHz.
However if you are not cautious, you may not achieve the maximum clock speed the device could achieve.If u are not careful (sometimes it happens) the controller would run at lower clock.Obviously that is not a bad thing in power critical applications.Here are some steps to ensure the system is running at its peak performance
STEP 1:
Download clock configuration tool from ST, file named AN3988
http://www.st.com/internet/mcu/product/252149.jsp
STEP 2:
Open the clock configuration tool using excel and change HCLK to 168 MHz.You can select on other options and PLL frequencies also (Know what you are doing else leave it as it is).Click generate.If values are OK then no errors would be shown.Then click on generate.Then close the excel file.You should have got a system_stm32f4xx.c file in the folder.Use it in your project.
STEP 3:
In stm32f4xx.h file ensure HSE (external clock) value is 8 MHz
STEP 4:
In startup_stm32f4xx.c file change comment on SystemInit() function
However if you are not cautious, you may not achieve the maximum clock speed the device could achieve.If u are not careful (sometimes it happens) the controller would run at lower clock.Obviously that is not a bad thing in power critical applications.Here are some steps to ensure the system is running at its peak performance
STEP 1:
Download clock configuration tool from ST, file named AN3988
http://www.st.com/internet/mcu/product/252149.jsp
STEP 2:
Open the clock configuration tool using excel and change HCLK to 168 MHz.You can select on other options and PLL frequencies also (Know what you are doing else leave it as it is).Click generate.If values are OK then no errors would be shown.Then click on generate.Then close the excel file.You should have got a system_stm32f4xx.c file in the folder.Use it in your project.
STEP 3:
In stm32f4xx.h file ensure HSE (external clock) value is 8 MHz
STEP 4:
In startup_stm32f4xx.c file change comment on SystemInit() function
to
STEP 5:
On the same file down under there will be a function Default_Reset_Handler(void)after assembly code towards the end add a line of code calling SystemInit() BEFORE calling main()
ie, change to
SystemInit();
main();
That`s it!
now in main function we can add
RCC_HSEConfig(RCC_HSE_ON);
while(!RCC_WaitForHSEStartUp())
{
}
this ensures HSE is enabled and will wait for clock to be stabilized.
Hope this helps
SIR,
ReplyDeleteI HAVE A STM32F4-DISCOVERY BOARD & I WANT TO PASS LOOK-UP TABLE ( STORED IN FLASH ) THROUGH ANY ONE GPOI PORT OF IT...(THE DATAS ARE ALL 16 BIT)
& I NEED EACH 16 BIT DATA IN ONE INSTRUCTION TO OUT AT PORT PIN (i.e. NOT AS 2 SUCCESSIVE 8 BIT DATA BY 2 CONSECUTIVE CYCLE OF CLK OR LIKE )IT MAY BE 32 BIT DATA .WITH PADDED ZEROS ...U CAN OFFER ANY CLK SPEED ...grateful to you..for your previous post also... helped me a lot for my final year project... I like to have a chat with u at your will
sending 16bit data can be easily done by writing the ODR register of the port in an instruction say, GPIOA-> ODR &= (16-bit data).Glad that the posts was something useful for you! regards
ReplyDeletewhat do we do if the excel tool won't work in Excel 2010 ?
ReplyDeletepccmd@comcast.net
It should be compatible i used office 2010 to view it.never had any problem.try reinstalling it
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHi Thank you for this article.
ReplyDeleteI am trying to use HSI and PLL. I am NOT using the Excel tool.
I am not sure if I'm doing it right. PLL ready flag is not set.
I have included the following code in my main.c
//------ To Select PLL source clock ---------------
RCC->PLLCFGR &= ~RCC_PLLCFGR_PLLSRC; // Enable HSI for PLL source
//*************To set PLL out put as 152MHz***********************
// VCO ip clock freq (VCO ip/PLLM) => HSI/16 => 1Mhz
// PLLM = 16
RCC->PLLCFGR &= ~RCC_PLLCFGR_PLLM;
RCC->PLLCFGR |= RCC_PLLCFGR_PLLM_4;
// VCO op => VCO ip x PLLN => 1 * 304 => 304MHz
// PLLN = 304 => B100110000
RCC->PLLCFGR &= ~RCC_PLLCFGR_PLLN;
RCC->PLLCFGR |= RCC_PLLCFGR_PLLN_4;
RCC->PLLCFGR |= RCC_PLLCFGR_PLLN_5;
RCC->PLLCFGR |= RCC_PLLCFGR_PLLN_8;
// PLL op => VCO op/PLLP => 304/2 => 152Mhz
// PLLP = 2
RCC->PLLCFGR &= RCC_PLLCFGR_PLLP;
//--- Turn ON PLL
RCC->CR |= RCC_CR_PLLON;
//---- Wait for PLL lock
while( !(RCC->CR & RCC_CR_PLLRDY) ); // GET STUCK HERE
//------ SET PLL output as SYS clock -------
RCC->CFGR &= 0xfffffffe;
RCC->CFGR |= RCC_CFGR_SW_PLL;
I am ok running Sys Clock directly by HSI at 16Mhz
Thank you
John
configuration de clock de microcontroleur
ReplyDeletepar exemple : fréquence1= 30 méga ,80 méga, 120 méga, Max
--------------------------------------------------------------------------------------
un volantaire pour travail ce projet SVP