Hi,
I want to use two UART on TM4C1294 LaunchPad. The project is extracted from udma_demo, TivaWare. UART0 is not changed, which echoes to/from the console. UART1 is configured in loopback. Now UART1 initialization has problem on how to send data to it. From below code, the last line
UARTSend((uint8_t *)"\033[2JEnter text:", 16);
in fact send data to UART0, not the intended UART1.
Can you help solving this problem? Thanks,
#define UART_TXBUF_SIZE 4
#define UART_RXBUF_SIZE 4
void
InitUART1_noDMA_Transfer(void)
{
uint_fast16_t ui16Idx;
//
// Fill the TX buffer with a simple data pattern.
//
for(ui16Idx = 0; ui16Idx < UART_TXBUF_SIZE; ui16Idx++)
{
g_ui8TxBuf[ui16Idx] = ui16Idx;
}
//
// Enable the UART peripheral, and configure it to operate even if the CPU
// is in sleep.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART1);
//
// Configure the UART communication parameters.
//
ROM_UARTConfigSetExpClk(UART1_BASE, g_ui32SysClock, 115200,
UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE);
//
// Set both the TX and RX trigger thresholds to 4. This will be used by
// the uDMA controller to signal when more data should be transferred. The
// uDMA TX and RX channels will be configured so that it can transfer 4
// bytes in a burst when the UART is ready to transfer more data.
//
ROM_UARTFIFOLevelSet(UART1_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8);
//
// Enable the UART for operation, and enable the uDMA interface for both TX
// and RX channels.
//
ROM_UARTEnable(UART1_BASE);
//
// This register write will set the UART to operate in loopback mode. Any
// data sent on the TX output will be received on the RX input.
//
HWREG(UART1_BASE + UART_O_CTL) |= UART_CTL_LBE;
//
// Enable the UART DMA TX/RX interrupts.
//
ROM_UARTIntEnable(UART1_BASE, UART_INT_DMATX | UART_INT_DMATX);
//
// Enable the UART peripheral interrupts.
//
ROM_IntEnable(INT_UART1);
UARTSend((uint8_t *)"\033[2JEnter text:", 16); // ??
}