Skip to main content
Dkuma.13
Associate II
July 14, 2020
Question

I am working on stm32g071. In which i am sending some log message from uart3. But after 8 - 10 hour it stop sending data. What could be the possible issue. Please guide. The sample of my main file is given below....

  • July 14, 2020
  • 2 replies
  • 1050 views

   /* Initialize all configured peripherals */

   MX_GPIO_Init();

   MX_SPI1_Init();

   MX_USART1_UART_Init();

   MX_USART2_UART_Init();

   MX_USART3_UART_Init();

   /* USER CODE BEGIN 2 */

   USART1->CR1 |= USART_CR1_RXNEIE_RXFNEIE; ///USART_CR1_RXNEIE;

   NVIC_SetPriority(USART1_IRQn, 1);

   NVIC_EnableIRQ(USART1_IRQn);

   USART2->CR1 |= USART_CR1_RXNEIE_RXFNEIE; ///USART_CR1_RXNEIE;

   NVIC_SetPriority(USART2_IRQn, 3);

   NVIC_EnableIRQ(USART2_IRQn);

   USART3->CR1 |= USART_CR1_RXNEIE_RXFNEIE; ///USART_CR1_RXNEIE;

   NVIC_SetPriority(USART3_4_LPUART1_IRQn, 2);

   NVIC_EnableIRQ(USART3_4_LPUART1_IRQn);

   GPIOB->ODR ^= GPIO_PIN_13;  // start modem

   GPIOB->ODR ^= GPIO_PIN_14;  //  glow led

   modemInit(); 

   gpsStart();

   while(getRssiValueInDbm()==0 && tt!=20){

      UARTSendString(logPort,(unsigned char *)"No network\r\n");

      HAL_Delay(100);

      tt++;

   }

   UARTSendString(logPort,(unsigned char *)"RSSI in dbm = \r\n");

   HAL_Delay(100);

   if(checkSimCardPresense()==1){

   sendRssiToRtu();

   }

   UARTSendString(logPort,(unsigned char *)"\r\n");

   HAL_Delay(1000);

   if(connectCheck()==0){

      HAL_Delay(100);

      mqttInit();

   }

//UARTSendString(logPort,(unsigned char*)"MODEM INIT END");

   UARTBufReset(rtuPort);

   /* USER CODE END 2 */

   /* Infinite loop */

   /* USER CODE BEGIN WHILE */

   startWatchdog();

   while (1)

   {

      /* USER CODE BEGIN 3 */

      Geardata gearData;

      PointMachineData pmData;

      resetWatchdog();

      index = -1;

      index = dequeue_pm_data(&pmData);

      if (index != -1)

         createJSONANDSendPMDataToMQTT(pmData);

      resetWatchdog();

      index = -1;

      index = dequeue_gear_data(&gearData);

      if (index != -1)

         createJSONANDSendGearDataToMQTT(gearData);

      /* Send RSSI to RTU in every 2 minute   */

      if(rssiTimeDelay==1){

         if(checkSimCardPresense()==1){

            sendRssiToRtu();

         }

         rssiTimeDelay=0;

      }

      /* Send GPS time to RTU in every 1 hour  */

      if(gpsRestartTime==1 || gpsFirstStart==1){

         if(gpsTimeToRtu()!=0){

            gpsFirstStart=0;

            gpsRestartTime=0;

         }

      }

   }

   /* USER CODE END 3 */

   //}

}

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
July 14, 2020

Identify sites where failure can occur, use bisection to narrow down the candidates.

Monitor stack usage.

Instrument the Hard Fault Hander and Error Handler routines so they output actionable information if they are reached.

Toggle LEDs on entry/exit for interrupts, or use GPIO you can scope.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Dkuma.13
Dkuma.13Author
Associate II
July 15, 2020

Thank you for your reply...

My program should restart after any problem, because I had used watchdog. Is there any condition in which controller stuck after using watchdog ??

One week ago, I have install seven devices in field. Three is steel working and four stopped. My device is used to take data through uart from other device and send to mqtt server.

Tesla DeLorean
Guru
July 15, 2020

>>Is there any condition in which controller stuck after using watchdog ??

If the NRST pin is driven high with a push-pull driver from some other chip or circuit, the STM32 won't restart properly

The device might restart, but issues in the code between Reset_Handler and main() might cause it to look broken/stuck. Basic debugging techniques, like outputting waypoint or progress indications to UART, GPIO or LEDs might help identify where it gets stuck, or whether it restarts properly out of a Watchdog event.

Need to review testing and diagnostic expectations.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
S.Ma
Principal
July 15, 2020

what is the ratio between baud rate vs clock tolerance?