2016-03-07 01:57 AM
Hi,
I am newbie for use the STM32 Timer, now i have a project for use the timer to do some jobs with periods, in the details.My project used MCU is STM32L151RCT6, i connected a GPS module to USART3 port to receive the GPS data, the USART3 configured with DMA mode (DMA1 channel 3, normal mode, very higher priority) with CubeMX, now my codes if just use the HAL_Delay(sometime) in looping, i can received the data from GPS without problem, the USART3 DMA channel 3 can keeping working as expected. But now, i want to change to timer for that function, because the GPS need even up to 30 seconds to fix satellites then output usable data. if just use the HAL_Delay(sometime) in looping that will be whole MCU in the waiting. Thus, i changed to timer, first start the timer10 and set up a 30 seconds timer and power on GPS module, meanwhile, i do the other stuff in my codes, when the timer10 expired, it will create a interrupt, then i put the USART3 DMA initial codes and try to receive the data from GPS as it is been 30s for locating satellites. now the problem is the timer10 can working well for start and expired in 30s and call to the interrupt(i putted a debug printf in there, i can saw it called success when timer expired), but the USART3 DMA initial is not success i never got the DMA working and never got the data from GPS(put a debug printf in the DMA interrupt callback routine).I have tried to change the timer10 global priority to lower (default is 0, tried to change to 1, 7, 15 with group 4bits in the CubeMX), but never helped ;(So, my question is can i use a timer just like this way? here is some codes i tested//timer 10 start called functionvoid GPS_Lookup_Start(void){ printf(''Started GPS timer\r\n''); GPS_PowerOn(); gpsDataReady = 0; printf(''GPS is Power ON.....\r\n''); __HAL_TIM_CLEAR_IT(&htim10, TIM_IT_UPDATE); HAL_TIM_Base_Start_IT(&htim10); //Start the 30 secs interrupt timer}//timer 10 expired called back function from its interuptvoid GPS_Lookup_Stop(void){ printf(''GPS timer expired, checking GPS data...\r\n''); HAL_TIM_Base_Stop_IT(&htim10); HAL_Delay(1000); GPS_Serial_init(); HAL_Delay(100); GPS_Receive(); if (gpsDataReady == 1) { HAL_TIM_Base_Stop_IT(&htim10); printf(''GPS data ready...\r\n''); } else { printf(''GPS timer starting again...\r\n''); __HAL_TIM_CLEAR_IT(&htim10, TIM_IT_UPDATE); HAL_TIM_Base_Start_IT(&htim10); //Start the 30 secs interrupt timer }} #!timer #!stm32