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.

Tiva TM4C123GH6PM UARTs PROBLEM

Other Parts Discussed in Thread: TM4C123GH6PM

Hello,

I made a test board for  TM4C123GH6PM .

I want TRY use UART port. But just UART0 working without problem.

UART1-7 not working.

My code is there,i just changed port and uart value when trying other uart:

where is the problem?

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

#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"

static char send[100];
int i;

int deviceAddress;

int
main(void)
{

SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_OSC|SYSCTL_XTAL_16MHZ| SYSCTL_OSC_MAIN);

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);


SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);


UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 9600,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |UART_CONFIG_PAR_NONE));


UARTEnable(UART0_BASE);


GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);


while(1)
{

SysCtlDelay(4000000);

sprintf(send,"hi man this is tiva\r\n");

i = 0;

while(send[i]!='\0')
{
UARTCharPut(UART0_BASE, send[i]);
i++;
}
}
////////////////////////////////////////////}

 

  • MAHMUT CETIN said:
    But just UART0 working without problem.

    Appears that you've landed w/in the trap set by the "default" behavior of PA0/PA1 - on many such parts.  Those 2 pins "wake from reset" in a manner different from all other (potential) UART pins.  This - and other pins with unique, default behavior - are detailed w/in the GPIO Section of your MCU manual.

    Thus - your copy/paste, "model" of PA0/PA1 code - in the attempt to "extend" UART capability elsewhere - will fail.

    Suspect that your addition of the "normal/customary" GPIOPinConfigure() - set up for UART - will resolve your issue...  Note that while you may GPIOPinType() pins in multiple - GPIOPinConfigure() must be employed singularly.  (i.e. on a per pin, basis)

        ROM_GPIOPinConfigure(GPIO_PXn_UnRX);  //  where n, m denote port pin and Uart port
        ROM_GPIOPinConfigure(GPIO_PXm_UnTX); 

  • thanks cb1_mobile,

    when i tried added your code my project, it s give an error like this:

    main.c(38): error: #20: identifier "GPIO_PC4_U4RX" is undefined
    main.c(39): error: #20: identifier "GPIO_PC5_U4TX" is undefined

    But added pinmap.h library.

    and i solved this problem like that and uart4 working now. I coppied and pasted this pin definition from pinmap.h up to my code. Problem was solved.

    Problem is keil not include pinmap.h when already definition this lib..

    Why?

    My last code is below:

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


    #include <stdint.h>
    #include <stdbool.h>
    #include <string.h>
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/debug.h"
    #include "driverlib/fpu.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"

    #define GPIO_PC4_U4RX 0x00021001
    #define GPIO_PC5_U4TX 0x00021401

    #define GPIO_PE4_U5RX 0x00041001
    #define GPIO_PE5_U5TX 0x00041401

    static char send[100];
    int i;

    int
    main(void)
    {

    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

    GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_5);


    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART4);SysCtlPeripheralEnable(SYSCTL_PERIPH_UART5);

    GPIOPinConfigure(GPIO_PC4_U4RX);GPIOPinConfigure(GPIO_PE4_U5RX);
    GPIOPinConfigure(GPIO_PC5_U4TX);GPIOPinConfigure(GPIO_PE5_U5TX);

    GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5);
    GPIOPinTypeUART(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5);

    UARTClockSourceSet(UART4_BASE, UART_CLOCK_PIOSC);
    UARTClockSourceSet(UART5_BASE, UART_CLOCK_PIOSC);

    UARTConfigSetExpClk(UART4_BASE, SysCtlClockGet(), 9600,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |UART_CONFIG_PAR_NONE));
    UARTConfigSetExpClk(UART5_BASE, SysCtlClockGet(), 9600,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |UART_CONFIG_PAR_NONE));

    while(1)
    {

    GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_PIN_5);

    SysCtlDelay(400000);

    GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, 0);

    SysCtlDelay(400000);



    sprintf(send,"tiva UART4 \r\n");


    i = 0;

    while(send[i]!='\0')
    {
    UARTCharPut(UART4_BASE, send[i]);

    i++;
    }

    sprintf(send,"tiva UART5 \r\n");
    i = 0;

    while(send[i]!='\0')
    {

    UARTCharPut(UART5_BASE, send[i]);
    i++;
    }



    }
    }

  • My friend - method you've chosen is not the way to go! 

    Adding those defines individually - as you've done - strongly suggests that your IDE has not been properly set-up/ configured.  (I would bet that you've attempted to create "your own project.") 

    As you may have noted pin_map.h is a massive file - and your IDE must "know" the identity of your MCU - to navigate pin_map.h with success. 

    Suggest that you open and well review a "factory supplied" project - and look for any/all MCU identity appearances.  Almost certainly - that MCU identity is missing/incorrect - in your project...

    Perhaps time now for hallowed, "Verify Answer" tick?

  • cb_1 is correct, you are missing a define for the part that you are using.  That is how pin_map.h knows how to define the correct pins.  In your case you need to add a define for "PART_TM4C123GH6PM" to your project to get the proper defines for your part.

  • Thanks cb1_mobile  and Paul,

    I know this way is not correct but i didn't find a correct way.

    cb1_mobile you correct i made new uvision project., i choose always this.

    Now, problem is solved by correct way.

    Thanks Paul. I added  "rvmdk PART_TM4C123GH6PM" my projects options tab 

    "C/C++ > Preprocessor Symbols > define"

    So,

    1- What does it mean? "rvmdk PART_TM4C123GH6PM" ?

    2- Is there any document or application note for all required setting? Are we will learn every setting from example project or forum like this?

    thanks everybody again.

  • The PART_* definition is in the documentation for GPIOPinConfigure(), but I will admit it is pretty light documentation.  We probably need some example code to show how to use this and a section on the compiler defines that we use as a part of DriverLib.  That really is a hole in the documentation that makes it difficult to start a project from scratch. 

  • Our group finds Paul's frank response accurate & especially refreshing.  Bravo, Paul.

    In fairness - you do provide a wealth of documentation - above/beyond most - and you make the effort to support multiple IDEs - adding further complexity to this task.

    As Paul has past advised - and our group fully supports - the desire to, "create/start a project from scratch" is most challenging - and rarely achieved quickly or easily.  (and - seldom is this "create/new" motivation explained or justified...)

    A reasonable alternative is to select the "best matching, factory supplied project" - and add your unique functions as/if/where needed.  All of the critical linkages and required set-up details have been properly supplied - and tested - following this, "use pre-built project" method.   Unneeded functions w/in the existing project - may then be selectively bypassed (commented out) - and the user is freed from "total mastery" of the IDE - and thus better enabled to focus on the MCU and the real demands of his/her project...

  • ok, i understood. thank s everybody for all helps.

    see you.