This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

uart to pc communication TM4C129XNCZAD

Other Parts Discussed in Thread: TM4C129XNCZAD, EK-TM4C1294XL

hi,

    i m working on UART protocol  i cant able to see the output on PUTTY Terminal below i attached the code please help me

#include<stdint.h>
#include<stdbool.h>
#include<driverlib/sysctl.h>
#include<inc/hw_gpio.h>
#include<inc/tm4c129xnczad.h>
void printchar( char c);
char readchar();
void printstring(char *string);
char c;
int main()
{
SYSCTL_RCGCUART_R=0x00000001;    //UART0
SYSCTL_RCGCGPIO_R=(1<<0);      //enable clock to porta gpio
GPIO_PORTA_AHB_AFSEL_R=(1<<0)|(1<<1);
GPIO_PORTA_AHB_PCTL_R=(1<<0)|(1<<4);
GPIO_PORTA_AHB_DEN_R=(1<<0)|(1<<1);
UART0_CTL_R&=~(1<<0);
UART0_IBRD_R=104;
UART0_FBRD_R=11;
UART0_LCRH_R=(1<<4);
UART0_CC_R=0X0;
UART0_CTL_R=(1<<0)|(1<<8)|(1<<9);
SYSCTL_RCGCGPIO_R=(1<<14);
GPIO_PORTQ_DIR_R=(1<<7)|(1<<4);
GPIO_PORTQ_DEN_R=(1<<7)|(1<<4);
GPIO_PORTQ_DATA_R &=~(1<<7)|(1<<4);
while(1)
{
printstring("enter \"r\",\"g\",or \"b\":\n\r");
c=readchar();
printchar(c);
printstring("\n\r");
switch(c)
{
case 'r':
GPIO_PORTQ_DATA_R=(1<<7); //red led on
break;
case 'g':
GPIO_PORTQ_DATA_R=(1<<4);
break;
case 'b':
GPIO_PORTQ_DATA_R=(1<<7);
break;
default:
GPIO_PORTQ_DATA_R=~((1<<7)|(1<<4));
break;
}
}
}


char readchar()
{

while((UART0_FR_R &(1<<4))!=0);
c=UART0_DR_R;
return c;
}
void printchar(char c)
{
while((UART0_FR_R &(1<<5))!=0);
UART0_DR_R=c;
}

void printstring(char *string)
{
while(*string)
{
printchar(*(string++));
}
}

  • Hello Basawaraj,

    I would suggest you have a look at the "Hello" project given in the TivaWare library as a reference and compare what you did to what is done there. If you installed to the default path it would be at C:\ti\TivaWare_C_Series-2.1.1.71\examples\boards\ek-tm4c1294xl\hello

    Also, make sure you are using the right port on the board for the UART you are using and that your baud rate, stop bits, parity, etc are matched between your device and the PUTTY config.
  • Hello Davenport,
    My question is UART To PC communicatio but you r telling that look at display driver example(HELLO example)
  • Did you have a look at the example Dave pointed to ?

    You would have noticed that those examples use the tested and portable TivaWare API (which is in ROM, and does not cost you any Flash), and avoid hacking directly into peripheral registers. Not much people are willing to wade through dozens of Ref. manual pages, to check that your settings are correct.

    Are you aware that you need a level shifter ? GPIO output from the MCU is not RS232 level compliant, and does not work.

    Did you check the output on the TX GPIO pin with a scope ?

    To test the correct UART initialization, you can connect TX directly to RX.  You could then receive all bytes you send.

  • A similar (but less boring) tale:

    Kid, "Hey Mom - can I do xyz?"

    Mom, "No!"

    Kid, "Hey Dad - can I do xyz?"

    Dad, "Yes."

    Later... Mom to Dad, "Why'd you tell kid it was ok?"

    In, "Kid herding" and "Forum herding" - consistency is key.

    Some here advise against the added complexity (always) introduced by the (unjustified/unexplained) "Use of DRM."   And some here allow it to pass w/out ANY mention!  

    Absent (reasonable) Forum consistency - and lacking ANY, "Poster Guidelines" - forum (like an inconsistent family) surely suffers.

    (pity that outsiders (aunts/uncles "poster f.m. here") have better Rule Enforcement than insiders (parents).)   A "suggested answer" which avoids (leaves silent) the unwanted, unproductive use of DRM - may not prove effective...

  • Hello Basawaraj,

    Did you check if the ICDI drivers are correctly showing up UART Serial in the Windows Device Manager?

    Regards
    Amit
  • Hello Amit,
    I checked drivers r installed correctly when i debuugging the above code
    void printstring(char *string)
    {
    while(*string)
    {
    printchar(*(string++));
    }
    }
    its not showing the string passed to it in PUTTY terminal please help me regarding this problem thanks for ur help
    and also while debugging its not come out of the loop line while((UART0_FR_R &(1<<4))!=0);
  • Hello Basawaraj

    Instead of looking at the code snapshot and debugging the snapshot, I will suggest a few things

    1. If the device is in debug mode, and the UART register space is open, then the debugger may read the data causing the firmware to hang in a while loop. You need to make sure that no register/memory window into UART address space is open
    2. Did you run one of the existing example code using UART like "hello", to see if with a fixed and tested binary your setup is working.

    Regards
    Amit