AnsweredAssumed Answered

Problem With USART

Question asked by moradiya.bhavesh on Mar 22, 2017
Latest reply on Mar 22, 2017 by moradiya.bhavesh

Hi,

 

I am using 3 USART in my code, But I faced a one ridiculous problem with them.

USART2 configured on interrupt and working fine I have No problem with this one. 

I Initialize the USART3(POL) first and send some data at this time its working fine and after I initialize USART2(INT) is also working fine and in last USART1(POL) also working fine.

 

Now let's come to problem.

I initialize all USART but I don't no what happen code stuck in usart GET STATUS flag function.

here is my main function.

 

int main(void)
{
   SystemInit();
   SysTick_Config(SystemCoreClock / 1000);
   GPIO_Init__();
   GPIO_Initialize_Conf();
   Module_switch();

   USART1_CONFIG();  //USART1 initialize for Bluetooth

   USART3_CONFIG();
   USART3_Send("$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28\r\n");
   delay____(1);  // 1 ms

   GPRS_Config();  //USART2 initialize here with INT
   SENSOR_Init(); //Initialize I2C1 & I2C2

   RTC_NVIC_ALR(00:00:00, WFI, 1); //Initialize RTC
   while (1)
   {
      for(volatile int i = 1;  i <= 10;  i++)
      {

         USART1_CONFIG();  // I must have to re-initialize USART1 here again and again

         Resolve_ERROR();  //USART1 used in this function. also work for OTA update over Bluetooth.

                                            //USART2 also used in this function for reconnection with server and OTA update from server.
         GET_Sensor(Sensor); //Get sensor data from I2C1 & I2C2
         USART3_CONFIG();  // I must have to re-initialize USART3 here again and again
         GET_GPS(read_gps);
         USART2_Send(Data, "\n"); 

      }
      SysTick -> CTRL = 0;
      Sleep_(00:01:00); //Sleep for 1 Min.

   }

}

 

I want to need some proper solution which can save my controller cycle which currently totally waste by this two USART

If I remove USART1 and USART3 config function from the "FOR" loop, code stuck in "USART_GetFlagStatus", I cant understand whats going on. 

Outcomes