I am beginner with this TM4C and have just learnt the basics of the board. I need to use the printf function for UART. the problem is the program gives no build error or warning but show no output on putty.
Any help would be appreciated.
UART initialization(UART.c)
#include <stdio.h> #include "UART.h" #include "tm4c123gh6pm.h" void UART_Init(void){ SYSCTL_RCGCUART_R |= 0x01; SYSCTL_RCGCGPIO_R |= 0x01; while((SYSCTL_PRGPIO_R&0x01) == 0){}; UART0_CTL_R &= ~UART_CTL_UARTEN; UART0_IBRD_R = 27; UART0_FBRD_R = 8; UART0_LCRH_R = (UART_LCRH_WLEN_8|UART_LCRH_FEN); UART0_CTL_R |= UART_CTL_UARTEN; GPIO_PORTA_AFSEL_R |= 0x03; GPIO_PORTA_DEN_R |= 0x03; GPIO_PORTA_PCTL_R = (GPIO_PORTA_PCTL_R&0xFFFFFF00)+0x00000011; GPIO_PORTA_AMSEL_R &= ~0x03; } char InChar(void) { while((UART0_FR_R&UART_FR_RXFE)!=0); return((char)(UART0_DR_R&0xFF)); } void OutChar(char data) { while((UART0_FR_R&UART_FR_TXFF)!=0); UART0_DR_R = data; } void OutString(char *pt) { while(*pt) { OutChar(*pt); pt++; } } void InString(char *inptr, unsigned long max) { int length=0; char character; character = InChar(); while(character != ENTER_Key) { if(character == BS_Key) { if(length) { inptr--; length--; OutChar(BS_Key); } } else if(length < max) { *inptr = character; inptr++; length++; OutChar(character); } character = InChar(); } *inptr = 0; } void OutENTER_LF() { OutChar(ENTER_Key); OutChar(LF); } int fputc(int ch, FILE *f) { if((ch==10)||(ch==13)||(ch==27)) { OutChar(13); OutChar(10); return 1; } OutChar(ch); return 1; } int fgetc(FILE *f) { char ch= InChar(); OutChar(ch); return ch; } int ferror(FILE *f) { return EOF; }
And the main file is
main.c
#include "tm4c123gh6pm.h" #include "PLL.h" #include "UART.h" #include <stdio.h> int main(void) { PLL_Init(); // 50MHz UART_Init(); printf("Using printf!!!\n"); }
thanks in advance.