Part Number: EK-TM4C1294XL
I am currently trying to develop in ARM Keil and am having some difficulty in testing the UART in loop back mode.
Below is the code I am using (the registers sets are structs, which does make things easier to read) I tried to use loop back, sending 1 character "U", but I don't see that result when I inspect the DR register after the send.
//MANUAL UART SETUP OF UART 0 and 1 as well as GPIO ports START
SYSCTL->RCGCUART |= 0xFF;
SYSCTL->RCGCGPIO |= 0x3;
GPIOA_AHB->DIR |= 0x2; //sets
GPIOA_AHB->DEN |= 0x3;
GPIOA_AHB->AFSEL |= 3;
GPIOB_AHB->DIR |= 0x2;
GPIOB_AHB->DEN |= 0x3;
GPIOB_AHB->AFSEL |= 3;
GPIOA_AHB->PCTL |= GPIO_PA0_U0RX | GPIO_PA1_U0TX;
GPIOB_AHB->PCTL |= GPIO_PB0_U1RX | GPIO_PB1_U1TX;
//MANUAL UART SETUP END
//SET UP BAUD FOR UART 0 START
UART0->CTL &= ~0x1; //clear UARTEN
UART0->IBRD |= 10; //Set integer part of BDR (BDR = 20000/ ( 16 * baud)
UART0->FBRD |= 54; // equal to (IBRD - floor IBRD) * 64 + 0.5)
UART0->LCRH |= 0x60; //set WLEN to 8 bits
UART0->CC = 0; //set up to base clock divisor to RSCLKCFG.
UART0->DMACTL |= 3;
UART0->CTL |= (3 << 8); //enable TX and RX
UART0->CTL |= (1 << 7); //enable loop back
UART0->CTL &= ~0x1; //clear UARTEN
// //SET UP BAUD FOR UART 0 END
// //SET UP BAUD FOR UART 1 START
UART1->CTL &=~ 0x1; //clear UARTEN
UART1->IBRD |= 10; //Set integer part of BDR (BDR = 20000/ ( 16 * baud)
UART1->FBRD |= 54; // equal to (IBRD - floor IBRD) * 64 + 0.5)
UART1->LCRH |= 0x60; //set WLEN to 8 bits
UART1->CC = 0; //set up to base clock divisor to RSCLKCFG.
UART1->DMACTL |= 3;
UART1->CTL |= (3 << 8); //enable TX and RX
UART1->CTL |= (1 << 7); //enable loop back
UART1->CTL &= ~0x1; //clear UARTEN
while( UART1->FR & UART_FR_TXFF)
{
//While tx full, wait.
}
UART1->DR = (unsigned char)('x');
volatile unsigned char testResult[64];
if( UART1->FR & UART_FR_RXFE )
{
testResult[0] = UART1->DR;
testResult[1] = (unsigned char)('s');
testResult[2] = (unsigned char)('i');
}