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) {