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.