This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARM Cortex M4F (TM4C123GH6PM) UART not working

Hi,

I am trying to setup UART1 have done the setting for GPIO and UART both. The data which I transmit over UART is coming to UART_DR (I am using Keil and CMSIS core Library to code it and in simulation window I can read the data in UART_DR) but I am not getting anything on UART1 window or serial console in Keil debugger.

Here are my code snippets for configuring GPIO and UART along with main function.

///////////////////////////////////////////////////////////////////////////////////////////////////////////////

#define U1RX (1<<4)
#define U1TX (1<<5)
#define PORTC (1<<2)

#define TXFF (1<<5)
#define RXFE (1<<4)
#define UART1EN (1<<0)

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void GPIOC_Init()
{ SYSCTL->RCGCGPIO |= PORTC ; //Enable PORTC
GPIOC->AFSEL |= (U1TX | U1RX); // Set Pin Functions to Alternate Functions
GPIOC->PCTL = (GPIOC->PCTL & 0xFF00FFFF) + 0x00220000; //Set Alternate Functions to UART1 (PMC5 = 0x0010 and PMC4 = 0x0010)
GPIOC->DEN |= (U1TX | U1RX); //Enable Digital functionality to UART Pins (PC4 = 1 and PC5 = 1)
GPIOC->AMSEL &= ~(U1TX |U1RX);

}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void UART_Init()
{ SYSCTL->RCGCUART = 0x02; // Enable UART1
UART1->CTL |=~UART1EN ; //Disable UART before configuration

UART1->IBRD = 0x08;
UART1->FBRD = 0x2C; // Baud Clock is 16MHz and BR = 115200
UART1->LCRH = 0x60; // 8N1, FEN disabled
UART1->CC = 0x5; // Select clock source as PIOSC System Clock
UART1->CTL |= UART1EN; // Enable UART

}

////////////////////////////////////////////////////////////////////////////////////////

void UART_Send(uint8_t data)
{ while((UART1->FR & TXFF)){}; // Wait till TX FIFO is Full

UART1->DR = data;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main()
{ uint8_t data[] = {"TM4C123GH6PM UART TX DEMO"};
uint8_t i, ch;

GPIOC_Init();
UART_Init();

for (i = 0; data[i] != '\0'; i++)
UART_Send(data[i]);

while(1);
}

I also have disabled clock setup in system_TM4C123.c file which is being used at startup. So after doing all this I am not understanding why m I not getting data on console while I get it in UART_DR?

0