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.

Uart7 not works

Other Parts Discussed in Thread: TM4C123GH6PM, MAX232

Hi,

I modified the uart_echo example for uart7. But it is not working. I saw many other posts related to that, but i can't get any output. Help me to resolve the problem. My code is,

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_ints.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/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"

#ifdef DEBUG
void
__error__(char *pcFilename, unsigned long ulLine)
{
}
#endif

void
UARTIntHandler(void)
{
unsigned long ulStatus;

ulStatus = UARTIntStatus(UART7_BASE, true);

UARTIntClear(UART7_BASE, ulStatus);

while(ROM_UARTCharsAvail(UART7_BASE))
{

ROM_UARTCharPutNonBlocking(UART7_BASE,
ROM_UARTCharGetNonBlocking(UART7_BASE));


GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);

SysCtlDelay(SysCtlClockGet() / (1000 * 3));

GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);

}
}

void
UARTSend(const unsigned char *pucBuffer, unsigned long ulCount)
{

while(ulCount--)
{

ROM_UARTCharPutNonBlocking(UART7_BASE, *pucBuffer++);
}
}

int
main(void)
{

ROM_FPUEnable();
ROM_FPULazyStackingEnable();

ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);

ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);

SysCtlPeripheralDisable(SYSCTL_PERIPH_UART0);

SysCtlPeripheralEnable(SYSCTL_PERIPH_UART7);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

GPIOPinTypeUART(GPIO_PORTE_BASE, GPIO_PIN_0);
GPIOPinConfigure(GPIO_PE0_U7RX);

GPIOPinTypeUART(GPIO_PORTE_BASE, GPIO_PIN_1);
GPIOPinConfigure(GPIO_PE1_U7TX);

ROM_UARTConfigSetExpClk(UART7_BASE, ROM_SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));

IntEnable(INT_UART7);
UARTIntDisable(UART7_BASE,UART_INT_TX);
UARTIntEnable(UART7_BASE, UART_INT_RX | UART_INT_RT);

IntMasterEnable();

UARTSend((unsigned char *)"\033[2JEnter text: %d", 16);

while(1)
{
}
}

  • Hello Bab,

    Which TM4C device are you using and how have you connected the UART7 Pins to your PC?

    Regards
    Amit
  • Hi Amit,

    I am using TM4C123GH6PM micro controller. I connected the PE0 and PE1 pin to the COM1 port of PC using Max232 IC with 115200 bps.
  • Hello Bab,

    Is the PC recognizing the COM Port in the Device Manager?

    Regards
    Amit
  • Hi Amit,

    I think it recognizes because in device manager as well in hyperterminal I configure the COM 1 port.
  • Hello Bab,

    1. Does the original unmodified uart_echo work?
    2. Then make a change to your existing code of turning PA0 and PA1 to Input GPIO and connect PE0 and PE1 to the TXD and RXD pins on the LaunchPad and then see if the modified code for uart_echo works. This will help isolate the software issue from any potential hardware issue.

    Regards
    Amit
  • Hi Amit,

    1.Yes the unmodified code works.
    2.The second point I will check.
  • Hi Amit,

    I tested with the following code by connecting PE0 and PE1 pins to TXD and RXD pins of launchpad. I didn't get any output (But LED blinks). Am I missed anything? 

    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_ints.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/interrupt.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    
    #ifdef DEBUG
    void
    __error__(char *pcFilename, unsigned long ulLine)
    {
    }
    #endif
    
    void
    UARTIntHandler(void)
    {
    unsigned long ulStatus;
    
    ulStatus = UARTIntStatus(UART7_BASE, true);
    
    UARTIntClear(UART7_BASE, ulStatus);
    
    while(ROM_UARTCharsAvail(UART7_BASE))
    {
    
    ROM_UARTCharPutNonBlocking(UART7_BASE,
    ROM_UARTCharGetNonBlocking(UART7_BASE));
    
    
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);
    
    SysCtlDelay(SysCtlClockGet() / (1000 * 3));
    
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);
    
    }
    }
    
    void
    UARTSend(const unsigned char *pucBuffer, unsigned long ulCount)
    {
    
    while(ulCount--)
    {
    
    ROM_UARTCharPutNonBlocking(UART7_BASE, *pucBuffer++);
    }
    }
    
    int
    main(void)
    {
    
    ROM_FPUEnable();
    ROM_FPULazyStackingEnable();
    
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
    SYSCTL_XTAL_16MHZ);
    
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    
    ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);
    
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);  //Newly added
    
    GPIOPinTypeGPIOInput(GPIO_PORTA_BASE,GPIO_PIN_0); //Newly added
    
    GPIOPinTypeGPIOInput(GPIO_PORTA_BASE,GPIO_PIN_1); //Newly added
    
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART7);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    
    GPIOPinTypeUART(GPIO_PORTE_BASE, GPIO_PIN_0);
    GPIOPinConfigure(GPIO_PE0_U7RX);
    
    GPIOPinTypeUART(GPIO_PORTE_BASE, GPIO_PIN_1);
    GPIOPinConfigure(GPIO_PE1_U7TX);
    
    ROM_UARTConfigSetExpClk(UART7_BASE, ROM_SysCtlClockGet(), 115200,
    (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
    UART_CONFIG_PAR_NONE));
    
    IntEnable(INT_UART7);
    UARTIntDisable(UART7_BASE,UART_INT_TX);
    UARTIntEnable(UART7_BASE, UART_INT_RX | UART_INT_RT);
    
    IntMasterEnable();
    
    UARTSend((unsigned char *)"\033[2JEnter text: %d", 16);
    
    while(1)
    {
    }
    }
  • Hello Bab,,

    So it makes sure that the software is all OK and the issue may be on the PC side software. Instead of using HyperTerminal, I would suggest using TeraTerm. Also when you start the Console Application, make sure that you press the board reset to see the text sent by the uC.

    In Tera Term, you do not need to make it COM1. Whatever the PC assigns the Port Number you can put the same in TeraTerm.

    Regards
    Amit
  • Hi Bab,

    Verify if your connection from TIVA MCU UART 7 to MAX232 is not reversed.

    - kel
  • Hi Kel,

    How can I verify that a pin transmit or data?. Actually I need to communicate between two zigbees. For that I am testing this with UART. Can you suggest that whether this code (posted) work to communicate between two zigbees.

  • Hello Bab

    Why would you need MAX232 to communicate with a ZigBee device?

    Regards
    Amit
  • Hi Amit,

    There is no need for MAX232, to communicate with ZigBee. Only to test the code with RS232 I am using MAX232. Can you reply me that, whether the posted code will work to communicate with ZigBee? and how can I check that, the data gets transmitted and recieved.

  • Hello Bab,

    What is ZigBee device since not any code will work with it. It surely must be expecting some form of command structure and w/o knowing what type of device it is, it would be tough to say.

    But theoretically, the code is well setup for UART communication in general.

    Regards
    Amit