滴答时钟计时修改systick记录

extern uint32_t SystemCoreClock;
..................................................................................................................................

 SystemCoreClock = HAL_RCC_GetHCLKFreq();
SysTick_Config(SystemCoreClock / 100);


....................................................................................................................................
1000是1ms , 100是10ms...............................

main中调用上面的就可以了....................当然要在HAL_Init();之后
已邀请:

admin

赞同来自:

int main(void)
{

/[i] USER CODE BEGIN 1 [/i]/

/[i] USER CODE END 1 [/i]/

/[i] MCU Configuration----------------------------------------------------------[/i]/

/[i] Reset of all peripherals, Initializes the Flash interface and the Systick. [/i]/
HAL_Init();

/[i] Configure the system clock [/i]/
SystemClock_Config();

/[i] Initialize all configured peripherals [/i]/
MX_GPIO_Init();

/[i] USER CODE BEGIN 2 [/i]/
SystemCoreClock = HAL_RCC_GetHCLKFreq();
SysTick_Config(SystemCoreClock / 100);
/[i] USER CODE END 2 [/i]/

/[i] USER CODE BEGIN 3 [/i]/
/[i] Infinite loop [/i]/
while (1)
{
if(addtime>=1000)
{
HAL_GPIO_TogglePin (GPIOF,GPIO_PIN_6);
addtime =0;
}
}
/[i] USER CODE END 3 [/i]/

}

要回复问题请先登录注册