diff --git a/exp2/Core/Inc/variable.h b/exp2/Core/Inc/variable.h index ca1c8fb..55d385e 100644 --- a/exp2/Core/Inc/variable.h +++ b/exp2/Core/Inc/variable.h @@ -9,6 +9,8 @@ extern "C" { typedef struct { uint8_t mMilSecCount; // 毫秒计数 uint8_t bTenMilSecOk; // 10毫秒标志位 + uint8_t mTenMilSecCount; // 10毫秒计数 + uint8_t bHundredMilSecOk; // 100毫秒标志位 uint8_t mTimeCount; // 秒计数 uint8_t bTimeOk; // 秒标志位 } stSysTickTimer; diff --git a/exp2/Core/Src/main.c b/exp2/Core/Src/main.c index 1cf3dbf..a5c334b 100644 --- a/exp2/Core/Src/main.c +++ b/exp2/Core/Src/main.c @@ -104,7 +104,9 @@ int main(void) if (sSysTickTimer.bTimeOk) { sSysTickTimer.bTimeOk = 0; HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin); - + } + if (sSysTickTimer.bHundredMilSecOk) { + sSysTickTimer.bHundredMilSecOk = 0; HAL_GPIO_WritePin(FlashLeds_GPIO_Port, nShift, GPIO_PIN_SET); diff --git a/exp2/Core/Src/stm32g4xx_it.c b/exp2/Core/Src/stm32g4xx_it.c index 0be82fa..76a8846 100644 --- a/exp2/Core/Src/stm32g4xx_it.c +++ b/exp2/Core/Src/stm32g4xx_it.c @@ -192,9 +192,13 @@ void SysTick_Handler(void) if (++sSysTickTimer.mMilSecCount >= 10) { sSysTickTimer.mMilSecCount = 0; sSysTickTimer.bTenMilSecOk = 1; - if (++sSysTickTimer.mTimeCount >= 100) { - sSysTickTimer.mTimeCount = 0; - sSysTickTimer.bTimeOk = 1; + if (++sSysTickTimer.mTenMilSecCount >= 10) { + sSysTickTimer.mTenMilSecCount = 0; + sSysTickTimer.bHundredMilSecOk = 1; + if (++sSysTickTimer.mTimeCount >= 10) { + sSysTickTimer.mTimeCount = 0; + sSysTickTimer.bTimeOk = 1; + } } } /* USER CODE END SysTick_IRQn 1 */