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.

TM4C123GH6PM: uart can only reccive less than 8 bytes

Part Number: TM4C123GH6PM

Hi,when I use tm4c123gh6pm test the uart  function,

when i test it I found that if the rx lenth is more than 10 bytes,it go to hardfault,but less than 8 is ok.

and if I set the rx count to zero it will broken rightly.

the code are as follows:

//UART
#define DEBUG_UART UART4_BASE
#define DEBUG_UART_PERIPH SYSCTL_PERIPH_UART4
#define DEBUG_UART_PORT SYSCTL_PERIPH_GPIOC
#define DEBUG_UART_RX GPIO_PC4_U4RX
#define DEBUG_UART_TX GPIO_PC5_U4TX
#define DEBUG_UART_PORT_BASE GPIO_PORTC_BASE
#define DEBUG_UART_RX_PIN GPIO_PIN_4
#define DEBUG_UART_TX_PIN GPIO_PIN_5

uint8_t Uart4Rx[64] = {0};
uint8_t Uart4Tx[64] = {1,2,3,4,5,6};

UARTRX_STRUCT DebugData;
void UART4IntHandler(void);

void PrintUsartInit(uint32_t baud)
{

GPIOPinConfigure(DEBUG_UART_RX);
GPIOPinConfigure(DEBUG_UART_TX);
GPIOPinTypeUART(DEBUG_UART_PORT_BASE,DEBUG_UART_RX_PIN|DEBUG_UART_TX_PIN);

UARTConfigSetExpClk(DEBUG_UART, SysCtlClockGet(), baud,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));

// IntMasterEnable();


UARTEnable(DEBUG_UART);
// UARTFIFOEnable(DEBUG_UART);
// UARTFIFOLevelSet(DEBUG_UART,UART_FIFO_TX4_8,UART_FIFO_RX4_8);
UARTIntEnable(DEBUG_UART, UART_INT_RX | UART_INT_RT);
UARTIntRegister(DEBUG_UART,UART4IntHandler);
IntEnable(INT_UART4);
}


void UART4IntHandler(void)
{
uint32_t ui32Status;
uint32_t tempData;
uint32_t rxCount = 0;
// Get the interrrupt status.
ui32Status = UARTIntStatus(DEBUG_UART, true);

// Clear the asserted interrupts.
UARTIntClear(DEBUG_UART, ui32Status);

// Loop while there are characters in the receive FIFO.
while(UARTCharsAvail(DEBUG_UART))
{
Uart4Rx [rxCount++] = UARTCharGetNonBlocking(DEBUG_UART) ;
}
DebugData.rxFlag = true;
// rxCount = 0;
}