The clock configuration about SysTick
Posted: Wed May 24, 2017 9:19 am
Good afternoon, I want to ask a question about STM32F051. The clock source of systick is 8 frequency division of HCLK and this is the datasheet of STM32F051: http://www.kynix.com/uploadfiles/pdf879 ... 51C4T6.pdf .
The code about my systick.c is given below:
[code]#include "Systick.h"
static __IO uint32_t TimingDelay;
void Delay_ms(__IO uint32_t nTime)
{
TimingDelay = (nTime*1000);
while(TimingDelay != 0);
}
void Delay_us(__IO uint32_t nTime)
{
TimingDelay = nTime;
while(TimingDelay != 0);
}
/**
* @brief Decrements the TimingDelay variable.
* @param None
* @retval None
*/
void TimingDelay_Decrement(void)
{
if (TimingDelay != 0x00)
{
TimingDelay--;
}
}
void Systick_Init(void)
{
if (SysTick_Config(SystemCoreClock / 1000000)) //1us
{
/* Capture error */
while (1);
}
}[/code]
And then invoking them in main:
[code] LED_Open();
Delay_us(500000);
LED_Close();
Delay_us(500000);[/code]
When in the file--it.c:
[code]void SysTick_Handler(void)
{
TimingDelay_Decrement();
}[/code]
Then the light can’t flash. Here the default is set to be frequency division.
2)It can operate normally before. The code is :
[code]void Systick_Init(void)
{
if (SysTick_Config(SystemCoreClock / 1000)) //1ms
{
/* Capture error */
while (1);
}
}[/code]
But when invoking them:
[code] LED_Open();
Delay_ms(500);
LED_Close();
Delay_ms(500);[/code]
The SystemCoreClock is set to be: “uint32_t SystemCoreClock = 48000000” and it haven’t be changed.
In this situation it is normal, why? ? ?
The code about my systick.c is given below:
[code]#include "Systick.h"
static __IO uint32_t TimingDelay;
void Delay_ms(__IO uint32_t nTime)
{
TimingDelay = (nTime*1000);
while(TimingDelay != 0);
}
void Delay_us(__IO uint32_t nTime)
{
TimingDelay = nTime;
while(TimingDelay != 0);
}
/**
* @brief Decrements the TimingDelay variable.
* @param None
* @retval None
*/
void TimingDelay_Decrement(void)
{
if (TimingDelay != 0x00)
{
TimingDelay--;
}
}
void Systick_Init(void)
{
if (SysTick_Config(SystemCoreClock / 1000000)) //1us
{
/* Capture error */
while (1);
}
}[/code]
And then invoking them in main:
[code] LED_Open();
Delay_us(500000);
LED_Close();
Delay_us(500000);[/code]
When in the file--it.c:
[code]void SysTick_Handler(void)
{
TimingDelay_Decrement();
}[/code]
Then the light can’t flash. Here the default is set to be frequency division.
2)It can operate normally before. The code is :
[code]void Systick_Init(void)
{
if (SysTick_Config(SystemCoreClock / 1000)) //1ms
{
/* Capture error */
while (1);
}
}[/code]
But when invoking them:
[code] LED_Open();
Delay_ms(500);
LED_Close();
Delay_ms(500);[/code]
The SystemCoreClock is set to be: “uint32_t SystemCoreClock = 48000000” and it haven’t be changed.
In this situation it is normal, why? ? ?