Other Parts Discussed in Thread: EK-TM4C123GXL
Hi,
I hope all are well.
I am testing TivaWare_C_Series-2.2.0.295 UART Echo example in Code Composer Studio Version: 12.0.0.00009 . I have successfully tested this example for UART 0 on EK-TM4C123GXL. Now I have changed this example for UART 2 on EK-TM4C123GXL. I have connected EK-TM4C123GXL PD6 UART2Rx to my USB-TTL Tx pin, and EK-TM4C123GXL PD7 UART2Tx to my USB-TTL Rx.
On my computer serial monitor test screen, i receive the string "Enter text " from EK-TM4C123GXL. But when i press keyboard key, then that character is not echoed back. Code is as follow. Please guide where is the issue. Thank you in advance.
Best Regards
Asim
//////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
//*****************************************************************************
//
// The UART interrupt handler.
//
//*****************************************************************************
void
UARTIntHandler(void)
{
uint32_t ui32Status;
//
// Get the interrrupt status.
//
ui32Status = MAP_UARTIntStatus(UART2_BASE, true);
//
// Clear the asserted interrupts.
//
MAP_UARTIntClear(UART2_BASE, ui32Status);
//
// Loop while there are characters in the receive FIFO.
//
while (MAP_UARTCharsAvail(UART2_BASE))
{
//
// Read the next character from the UART and write it back to the UART.
//
MAP_UARTCharPutNonBlocking(UART2_BASE,MAP_UARTCharGetNonBlocking(UART2_BASE));
}
}
//*****************************************************************************
//
// Send a string to the UART.
//
//*****************************************************************************
void
UARTSend(const uint8_t *pui8Buffer, uint32_t ui32Count)
{
//
// Loop while there are more characters to send.
//
while(ui32Count--)
{
//
// Write the next character to the UART.
//
MAP_UARTCharPutNonBlocking(UART2_BASE, *pui8Buffer++);
}
}
//*****************************************************************************
//
// This example demonstrates how to send a string of data to the UART.
//
//*****************************************************************************
int
main(void)
{
//
// Enable lazy stacking for interrupt handlers. This allows floating-point
// instructions to be used within interrupt handlers, but at the expense of
// extra stack usage.
//
MAP_FPUEnable();
MAP_FPULazyStackingEnable();
//
// Enable the peripherals used by this example.
//
MAP_SysCtlPeripheralDisable(SYSCTL_PERIPH_GPIOD);
MAP_SysCtlPeripheralReset(SYSCTL_PERIPH_GPIOD);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
while(!MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOD))
{
}
//unlock D7 pin from JTAG Operation
HWREG(GPIO_PORTD_BASE+GPIO_O_LOCK) = GPIO_LOCK_KEY;
HWREG(GPIO_PORTD_BASE+GPIO_O_CR) |= GPIO_PIN_7;
MAP_SysCtlPeripheralDisable(SYSCTL_PERIPH_UART2);
MAP_SysCtlPeripheralReset(SYSCTL_PERIPH_UART2);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2);
// Wait for the UART2 module to be ready
while(!MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_UART2))
{
}
MAP_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//
// Enable processor interrupts.
//
MAP_IntMasterEnable();
//
// Set GPIO D6 and D7 as UART pins.
//
GPIOPinConfigure(GPIO_PD6_U2RX);
GPIOPinConfigure(GPIO_PD7_U2TX);
MAP_GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_6 | GPIO_PIN_7);
//
// Configure the UART for 115,200, 8-N-1 operation.
//
MAP_UARTConfigSetExpClk(UART2_BASE, MAP_SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
//
// Enable the UART interrupt.
//
MAP_IntEnable(INT_UART2);
MAP_UARTIntEnable(UART2_BASE, UART_INT_RX | UART_INT_RT);
// Prompt for text to be entered.
UARTSend((uint8_t *)"\033[2JEnter text: ", 16);//AZUARTSend((uint8_t *)"\033[2JEnter text: ", 16);
//
// Loop forever echoing data through the UART.
//
while(1)
{
}
}