14. Example
Configure STM32 clock to 84 MHz from external clock generator
Algorithm:
1. Set FLASH latency.
2. Enable HSE. Check HSE Ready bit.
3. Set AHB, APB1 and APB2 prescaler.
4. Config PLL:
1. Set PLL clock source. Wait until switch operation complete.
2. Set PLL M, N and P prescalers.
3. Enable PLL. Wait PLL start.
5. Set Main clock switch to PLL source.
15. SysTick
//define main clock value
#define HCLK 84000000
//define System Tick Timer frequency
#define SysTicksClk 10000
//define System Tick Timer prescaler
#define SysTicks HCLK/SysTicksClk
void SysTick_Handler(void)
{
//SysTick Interrupt handler
}
int main()
{
SysTick_Config(SysTicks); //SysTick Enable and configuration
}