From 68939ce315b9a6fdfc14e4f7230cc86506118f8b Mon Sep 17 00:00:00 2001 From: fuxiaoer Date: Mon, 23 Oct 2023 19:43:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9C=AC=E5=9C=B0=E6=99=B6?= =?UTF-8?q?=E6=8C=AF=E9=92=9F=E5=B7=AE=E8=A1=A5=E5=81=BF=E7=B3=BB=E6=95=B0?= =?UTF-8?q?time=5Fscale?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Core/Src/global_var.c | 1 + Core/Src/stm32f1xx_it.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Core/Src/global_var.c b/Core/Src/global_var.c index c17d994..562b51e 100644 --- a/Core/Src/global_var.c +++ b/Core/Src/global_var.c @@ -19,4 +19,5 @@ uint8_t U1_TX_buf[UART_BF_SIZE]={0}; /* define var */ uint8_t ST_IMU_INT = 0, TDK_IMU_INT = 0; // IMU INT flag uint8_t U1_DMA_BUSY = 0; +double time_scale=1; int GPS_week; diff --git a/Core/Src/stm32f1xx_it.c b/Core/Src/stm32f1xx_it.c index 5841bd9..723aef9 100644 --- a/Core/Src/stm32f1xx_it.c +++ b/Core/Src/stm32f1xx_it.c @@ -67,6 +67,7 @@ extern UART_HandleTypeDef huart1; extern UART_HandleTypeDef huart2; /* USER CODE BEGIN EV */ extern TIM_HandleTypeDef htim3; +extern double time_scale; /* USER CODE END EV */ @@ -371,7 +372,7 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) IMU_mng_ST.ready = 1; IMU_mng_ST.gpstime = SYS_TIME.SYS_GPST_TIME; IMU_mng_ST.utctime = SYS_TIME.SYS_UTC_TIME; - IMU_mng_ST.gpstime.sec = IMU_mng_ST.utctime.sec = __HAL_TIM_GET_COUNTER(&htim3) / 10000.0; + IMU_mng_ST.gpstime.sec = IMU_mng_ST.utctime.sec = __HAL_TIM_GET_COUNTER(&htim3) / 10000.0*time_scale; } else { @@ -387,6 +388,9 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) else if (GPIO_Pin == PPS_INT_Pin) { /* Neet to add sec and clean Tim CNT */ + int timer_count =__HAL_TIM_GET_COUNTER(&htim3); + if (timer_count<12000 && timer_count > 8000) + time_scale=10000.0/timer_count; __HAL_TIM_SET_COUNTER(&htim3, 0); // clean TIM3 CNT if (SYS_TIME.NMEA_GET == 1) {