Other Parts Discussed in Thread: PROFIBUS
Hello everyone,
I have an issue with UART communication. I connected two tiva boards for UART serial communication (to simulate operation of custom electronics that I wait to be made). It is simple communication in which one board sends another board 1 byte of data twice (2 bytes), just to confirm the validity of data arrived. 2 bytes are sent on button click. I configured receiver board UART to interrupt on 2 bytes received, and that seems to work fine. Problem is that first time receive, system interrupts when the first byte is received and reads received byte and one byte of zeros. Each next receive is now shifted for me, since board reads remaining byte of previous msg and one byte of new msg. I tried reading data in FIFO in configuration function but seems that this does not work. How can I handle this, how can I make sure there is nothing in FIFO when system starts? Below is the code for receiver board UART.
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1); GPIOPinConfigure(GPIO_PC4_U1RX); GPIOPinConfigure(GPIO_PC5_U1TX); ROM_GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5); ROM_UARTConfigSetExpClk(UART1_BASE, ROM_SysCtlClockGet(), 115200,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE )); ROM_IntEnable(INT_UART1); ROM_UARTIntEnable(UART1_BASE, UART_INT_RX); UARTFIFODisable(UART1_BASE); UARTFIFOEnable(UART1_BASE); UARTFIFOLevelSet(UART1_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8); uint32_t dummy=0; while(UARTCharsAvail(UART1_BASE)) dummy = UARTCharGet(UART1_BASE);