I try to read only 1 byte from UART with the Interrupt, however, somehow while(UARTCharsAvail(UART0_BASE)) do not return true if the I'm not send 4 bytes. Is while(UARTCharsAvail(UART0_BASE)) only return true if the Receive FIFO have 32-bits data in it?
I try to send only 1 byte from PC to the UART. But somehow I can't read that byte unless I send 4 times. Is there any way I can just read 1 byte before I can do anything else?
Best regards,
void UARTIntHander(void){ uint32_t ui32Status; uint8_t data = 0; // // Get the interrrupt status. // ui32Status = UARTIntStatus(UART0_BASE, true); // // Clear the asserted interrupts. // UARTIntClear(UART0_BASE, ui32Status); // clear the asserted interrupts // // Loop while there are characters in the receive FIFO. // while(UARTCharsAvail(UART0_BASE)) // loop while there are chars // return if 32 bit is full. { data = UARTCharGetNonBlocking(UART0_BASE); UARTCharPutNonBlocking(UART0_BASE, data); //echo character } } void InitConsole(void) { IntMasterEnable(); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTStdioConfig(0, 115200, ui32SysClockFreq); // For interrupt IntEnable(INT_UART0); UARTIntEnable(UART0_BASE, UART_INT_RX); // trigger only in RX //UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); UARTFIFODisable(UART0_BASE); // Clear FIFO UARTFIFOEnable(UART0_BASE); }