2013-10-25 01:54 AM
Hi, I am working with STM32F401 discovery board.
I set up the system_stm32f4xx.c file so that the system clock becomes 84MHz(I used Excel based stm32 clock generator tool to get PLL values). void Delay(uint32_t dlyTicks){ msTicks = 0; while(msTicks<dlyTicks); } SystemInit(); SystemCoreClockUpdate();//Update variable SystemCoreClock //SysTick_Config(SystemCoreClock/1000); SysTick_Config(84000); If i do switch to the code that is commented out above, I get in accuracte timing for delay. The problem is that SystemCoreClock is read as 262500000. I don't understand why. Shouldn't it read 84000000 or 10500000? The un-commented code works fine and the SysTick seems to be operating at 84MHz clock. When I generated system_stm32f4xx.c file, I set up the Excel Wizard so that Systick runs at 10.5MHz. Why is it running at 84MHz? and how can I change it correctly?? Thank you.2013-10-25 03:58 AM
I'd just edit the file manually and understand the relationship between the clock settings.
Perhaps you have HSE_VALUE wrong? The DISCOVERY boards have an 8 MHz crystal, whereas the EVAL boards typically have an 25 MHz one. The relationship between the clocks is hardly complex.#if defined (PLL_SOURCE_HSI)
uint32_t SystemCoreClock = ((HSI_VALUE / PLL_M) * PLL_N) / PLL_P;
#else
uint32_t SystemCoreClock = ((HSE_VALUE / PLL_M) * PLL_N) / PLL_P;
#endif
If this gives the wrong answer, then some of the input variables are wrong.
2013-10-27 06:15 PM
https://www.dropbox.com/s/frna2zgdblnjbns/Clock%20Configuration%20Tool%20for%20STM32F40x%2c41x.xls
https://www.dropbox.com/s/7h698fbpy490xut/system_stm32f4xx.c
2013-10-28 04:50 AM
Consider using
STM32F401-Discovery_FW_V1.0.0\Projects\Template\system_stm32f4xx.c Make sure you define STM32F401xx for the project Alternatively consider #define PLL_N 336 #define PLL_P 4 #define PLL_M 8 #define PLL_Q 7uint32_t SystemCoreClock = ((HSE_VALUE / PLL_M) * PLL_N) / PLL_P;
This would run the part at 84 MHz, and also allow 48 MHz for the USB clock