HAL_GPIO_WritePin(GPIOB,GPIO_PIN_7,GPIO_PIN_SET);
__HAL_RCC_CLEAR_RESET_FLAGS();
Error_Handler();
}
HAL_FLASH_Unlock();
/* Fill EraseInit structure*/
EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
EraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3;
EraseInitStruct.Sector = FLASH_SECTOR_8;
EraseInitStruct.NbSectors = 1;
// if(HAL_FLASHEx_Erase(&EraseInitStruct, &SECTORError) != HAL_OK)
// {
// Error_Handler();
// }
beginTick =HAL_GetTick();
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_8,GPIO_PIN_SET);
curSysTick =SysTick->VAL;
if(HAL_FLASHEx_Erase_IT(&EraseInitStruct)!= HAL_OK) //擦除 sector8
{
Error_Handler();
}
endSysTick =SysTick->VAL; // curSysTick, endSysTick 保存着 SysTick 寄存器的值
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_8,GPIO_PIN_RESET); //PC8 波形表示擦除 FLASH 的时间间隔
endTick =HAL_GetTick(); // beginTick, endTick 保存着全局变量 Tick 的值
g_TickCount =endTick -beginTick; //变量 Tick 的时间差
HAL_IWDG_Refresh(&hiwdg);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
if (HAL_IWDG_Refresh(&hiwdg) != HAL_OK)
{
/* Refresh Error */
Error_Handler();
}
HAL_Delay(10);
}
/* USER CODE END 3 */
}
此外,同时在每个 SysTick 中断输出一个波形,用来检测 SysTick 是否正常: