This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C1231E6PM: UART losing data

Part Number: TM4C1231E6PM
Other Parts Discussed in Thread: EK-TM4C123GXL

Dear Sirs

I'm using the UART5 to communicate with a ESP8266 module.

This is the configuration

ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_INT);

ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART5);
ROM_GPIOPinConfigure(GPIO_PE4_U5RX );
ROM_GPIOPinConfigure(GPIO_PE5_U5TX);
ROM_GPIOPinTypeUART(GPIO_PORTE_BASE,GPIO_PIN_4 | GPIO_PIN_5 );
ROM_UARTConfigSetExpClk(UART5_BASE, ROM_SysCtlClockGet(), 9600,
                       (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
                        UART_CONFIG_PAR_NONE));

I'm pooling the serial port instead of using the interrupt. This is the function 

int recvString(char *target, char *data, int timeout, bool check)
{
	int i=0;
	char a;
	unsigned long start = millis();


    while (millis() - start < timeout)
    {
    	while(ROM_UARTCharsAvail(UART5))
    	{
              a = ROM_UARTCharGet(UART5);
              if(a == '\0')
                  continue;
              data[i]= a;
              i++;
    	}
    }
    	if(check)
    	{
    		if (SearchIndexOf(data, target) != -1)
    		{
    		    return 1; //break;
    		}
    	}


    return 0;
}

My problem is that the I'm missing some received data. The missing data is at the beginning of the transmission ,after some bytes are successfully read from  the buffer . The error is aleatory. Doesn't occurs always.

  • Do you have interrupt routines running while in this function? Is it possible that an interrupt routine is taking a long time and causing you to miss some of the data?
  • You are right. The interrupt routines are the problem.

    I'm implementing a circular buffer to receive data from the UART

    Regards

    Ysaac

  • You might want to look at your interrupt routines to see if you can move some of the processing time out of the interrupt routine into your main loop. If that won't work, this device supports nested interrupts. You can have 8 levels of interrupts. Program the NVIC so that UART5 is at a higher level (lower number) interrupt than your other routine. There is a TivaWare example that shows using different levels of interrupts in:
    C:\ti\TivaWare_C_Series-2.1.4.178\examples\boards\ek-tm4c123gxl\interrupts