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串口接收问题

各位好,小弟调试串口时遇到如下问题,使用串口接收,且一帧接收完成后补将数据地址重新移动到数组的其实位置可以接收,但是如果填充满后就接收不到新的数据了,但是如果将数据地址重新一到开头位置,如果数据小于8个字节正常,数据大于10个字节后就直接进入hardfault,请问有没有人遇到过?代码如下:

//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;
}