Part Number: F28M36H53C2
Tool/software: TI C/C++ Compiler
Hello,
I'm facing a configuration issue with UART FIFO.
My UART is configured as fallow:
void BSL_UartInit()
{
//Initialize the UART
//Set the baud rate = 115200
//Number of data bits = 8
//Turn off parity
//Number of stop bits = 1
UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(SYSTEM_CLOCK_SPEED), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
//Enable trasmit and receive FIFO
UARTFIFOEnable(UART0_BASE);
//Registers of UART interrupt
UARTIntRegister(UART0_BASE, UartIntHandler);
//Enable UART interrupt
UARTIntEnable(UART0_BASE, UART_INT_RX | /*UART_INT_RT |*/ UART_INT_BE);
//Enable the UART
UARTEnable(UART0_BASE);
UartTxFSM.status = UART_TX_FSM_IDLE;
}
So I write the follow code to receive data from UART:
#define UART_RX_BUF_LENGTH (32)
#define UART_ADDRESS (0x10)
#define END_BYTE 0x7E
struct {
enum {
UART_TX_FSM_IDLE,
UART_TX_FSM_TX_BREAK,
UART_TX_FSM_TX_DATA
} status;
unsigned char buf[UART_TX_FIFO_LENGTH];
unsigned char address;
//unsigned char len;
unsigned int len;
} UartTxFSM;
struct {
int idx;
int timeout;
int error;
unsigned char buf[UART_RX_BUF_LENGTH];
int len;
} UartRx;
void UartIntHandler(void)
{
unsigned long status;
char data;
unsigned char ck = 0xff;
//break received
if(status & UART_INT_BE)
{
UARTIntClear(UART0_BASE, UART_INT_BE);
data = UARTCharGetNonBlocking(UART0_BASE); //discard empty data
UartRx.idx = 0;
UartRx.timeout = 0;
UartRx.error = 0;
}
//if(status & UART_INT_RT)
//{
// UARTIntClear(UART0_BASE, UART_INT_RT);
// UartRxTimeout = 1;
//}
if(status & UART_INT_RX)
{
UARTIntClear(UART0_BASE, UART_INT_RX);
data = UARTCharGetNonBlocking(UART0_BASE);
if(UartRx.idx == UART_RX_BUF_LENGTH || data & 0x00000f00)
UartRx.error = 1;
else
{
UartRx.idx++;
UartRx.buf[UartRx.idx] = data & 0x000000ff;
ck += data;
}
}
}
At the end, the UartRx.buff contain only 0x7E value, that is the last value sent from the other device.
Am I missing something?