[liklon plays with GD32F350] 3. SYSTICK realizes simple delay[Copy link]
A little delay is needed during use. There is HAL_Delay in the HAL library that can be used, but the GD standard library is currently used, so systick is still needed to implement a simple delay function. 1. Systick tick timer Those who have used M3 M4 should be familiar with this, so I will not describe it again. In the GD32F3X0_MISC file, there is a function to configure the systick clock source:
/*! \brief set the systick clock source \param[in] systick_clksource: the systick clock source needed to choose \arg SYSTICK_CLKSOURCE_HCLK: systick clock source is from HCLK \arg SYSTICK_CLKSOURCE_HCLK_DIV8: systick clock source is from HCLK/8 \param[out] none \retval none */ void systick_clksource_set(uint32_t systick_clksource) { if(SYSTICK_CLKSOURCE_HCLK == systick_clksource ){ /* set the systick clock source from HCLK */ SysTick->CTRL |= SYSTICK_CLKSOURCE_HCLK; }else{ /* set the systick clock source from HCLK/8 */ SysTick->CTRL &= SYSTICK_CLKSOURCE_HCLK_DIV8; } }
复制代码
There is no introduction to the systick register in the gd manual. Here is a picture from the M4 authoritative manual
lsj306 posted on 2018-9-7 14:02 Hello, I use the timer interrupt to turn on and off the LED light, and it feels that the interrupt time difference is more than 10 times
Do you use the timer interrupt? You can take a look at my other post, General Timer 1