• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » Stellaris® ARM® Microcontrollers » Stellaris® ARM® LM3S Microcontrollers Forum » uart1 echo in lm3s9b92 help!
Share
Stellaris® ARM® Microcontrollers
  • Forum
Options
  • Subscribe via RSS

Forums

uart1 echo in lm3s9b92 help!

This question is not answered
Ruth Kodamala
Posted by Ruth Kodamala
on Apr 03 2012 05:11 AM
Prodigy40 points
HI everyone,
I have modified the UART0 echo code to use UART1..in order to communicate with uart1 through PC by making use of PD2 and PD3 pins as RX and TX pins
1.I am using a MAX232 level converter and connecting UART1 to PC through a DB9 connector
2. I have also changed the Interrupt Vector to UARTInthandler for Uart1 tx and rx
3. I am using the GPIOPin Configure also
4. HWREG is also used in order to assign the PD2  and PD3

#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"

//*****************************************************************************
//
//! \addtogroup example_list
//! <h1>UART (uart_echo)</h1>
//!
//! This example application utilizes the UART to echo text. The first UART
//! (connected to the FTDI virtual serial port on the evaluation board) will be
//! configured in 115,200 baud, 8-n-1 mode. All characters received on the
//! UART are transmitted back to the UART.
//
//*****************************************************************************

//*****************************************************************************
//
// The error routine that is called if the driver library encounters an error.
//
//*****************************************************************************
#ifdef DEBUG
void
__error__(char *pcFilename, unsigned long ulLine)
{
}
#endif

//*****************************************************************************
//
// The UART interrupt handler.
//
//*****************************************************************************
void
UARTIntHandler(void)
{
unsigned long ulStatus;

//
// Get the interrrupt status.
//
ulStatus = ROM_UARTIntStatus(UART1_BASE, true);

//
// Clear the asserted interrupts.
//
ROM_UARTIntClear(UART1_BASE, ulStatus);

//
// Loop while there are characters in the receive FIFO.
//
while(ROM_UARTCharsAvail(UART1_BASE))
{
//
// Read the next character from the UART and write it back to the UART.
//
ROM_UARTCharPutNonBlocking(UART1_BASE,
ROM_UARTCharGetNonBlocking(UART1_BASE));
}
}

//*****************************************************************************
//
// Send a string to the UART.
//
//*****************************************************************************
void
UARTSend(const unsigned char *pucBuffer, unsigned long ulCount)
{
//
// Loop while there are more characters to send.
//
while(ulCount--)
{
//
// Write the next character to the UART.
//
ROM_UARTCharPutNonBlocking(UART1_BASE, *pucBuffer++);
}
}

//*****************************************************************************
//
// This example demonstrates how to send a string of data to the UART.
//
//*****************************************************************************
int
main(void)
{
//
// Set the clocking to run directly from the crystal.
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);

HWREG(GPIO_PORTD_BASE + GPIO_O_PCTL) =
(HWREG(GPIO_PORTD_BASE + GPIO_O_PCTL) &
~(GPIO_PCTL_PD2_M | GPIO_PCTL_PD3_M)) |
(GPIO_PCTL_PD2_U1RX | GPIO_PCTL_PD3_U1TX);
//
// Enable the peripherals used by this example.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

//
// Enable processor interrupts.
//
ROM_IntMasterEnable();

//
// Set GPIO A0 and A1 as UART pins.
//
GPIOPinConfigure(GPIO_PD2_U1RX);
GPIOPinConfigure(GPIO_PD3_U1TX);
ROM_GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_2 | GPIO_PIN_3);

//
// Configure the UART for 115,200, 8-N-1 operation.
//
ROM_UARTConfigSetExpClk(UART1_BASE, ROM_SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));

//
// Enable the UART interrupt.
//
ROM_IntEnable(INT_UART1);
ROM_UARTIntEnable(UART1_BASE, UART_INT_RX | UART_INT_RT);

//
// Prompt for text to be entered.
//
UARTSend((unsigned char *)"\033[2JEnter text: ", 16);

//
// Loop forever echoing data through the UART.
//
while(1)
{
}
}


Can anyone Please check and tel me.. wat am i missing am able to get echo back for UART0 but not for UART1.. am totally frustrated have been trying alot and am desperate 
for a solution Pls Help me!!!
LM3S9B92 UART1 echo
Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • slandrum
    Posted by slandrum
    on Apr 03 2012 11:41 AM
    Mastermind9640 points

    Did you try running this with a debugger?

    If you had, you would have seen that your code was faulting almost immediately.

    You access peripheral registers before you enable the peripheral.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Ruth Kodamala
    Posted by Ruth Kodamala
    on Apr 03 2012 19:52 PM
    Prodigy40 points

    Hi Slandrum,

                               Thank you for pointing that out to me..  I have modified the code by placing this 


    HWREG(GPIO_PORTD_BASE + GPIO_O_PCTL) =
    (HWREG(GPIO_PORTD_BASE + GPIO_O_PCTL) &
    ~(GPIO_PCTL_PD2_M | GPIO_PCTL_PD3_M)) |
    (GPIO_PCTL_PD2_U1RX | GPIO_PCTL_PD3_U1TX);
    below this
     ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    But still there's no change ...
    Since I am a newbie to this IAR debugger which I am using.. I am still not understanding the fault.... 
    Can you please explain where I am going wrong.. I really need to understand this..
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • slandrum
    Posted by slandrum
    on Apr 04 2012 02:32 AM
    Mastermind9640 points

    Since you are using interrupts for the UART, have you modified the interrupt vector table so that the UART1 vector points to your interrupt handler?

    The interrupt vector table should be in a startup file, probably called something like startup_xxx.c where xxx is the name of the toolchain you are using.

    EDIT: Never mind, I now see that in your first post you say that you have done this.

    I don't use IAR, so someone else will have to help you with anything that's specific to IAR.  Normally for debugging something like this, it's useful to step through your code one function call at a time and see where it ends up in the fault handler.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • slandrum
    Posted by slandrum
    on Apr 04 2012 02:46 AM
    Mastermind9640 points

    Another thing I notice:

    Why are you calling the non-blocking version of UARTCharPut() in your UARTSend() function?  This is guaranteed to not do what you want when you try to send too many characters at a time, as the hardware FIFO will fill up, then you'll just drop the rest of the characters without sending them.  The non-blocking version of a function always returns immediately whether or not it can perform the desired operation, and you must check its return value to see whether or not it succeeded, unless you know in advance that it must succeed (for instance you know that there's room in the Tx FIFO for the next character), or you really don't care whether the call works or not.

    In general, you do not want to call the non-blocking versions of the functions when you really want the data to go out.  If you can do something else when the hardware is busy, for instance yield to other tasks, you can call the non-blocking version, check the result, and if it failed do a task yield then loop back and try again.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Ruth Kodamala
    Posted by Ruth Kodamala
    on Apr 10 2012 05:03 AM
    Prodigy40 points

    I have actually modified the uart_echo example provided by the stellarisware examples... For UART0 to UART1 ... 

    That is why the non blocking function has been called...

    I am still not clear as to where the problem is.. whether hardware or software..

    can u please tell me.. if my hardware connections are correct ?

    1.I have used a max232 level converter chip to connect the PD2 and PD3 pins of the GPIO port D for TXD and RXD

    2. the ground pins are also connected to the RS232 DB9 connector..

    Is there anythingelse am missing in the  hardware side..

    am making use of a usb to serial converter to communicate with the UART1 and my Laptop..from COM1 which uses the ProlificUSB toSerial 

    and the stellaris board uses COM9 both are configured to a Baud rate of 115200.

    Any help will be appreciated...

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
TI E2E™ Community
  • Support Forums
  • Blogs
  • Videos
  • Groups
  • Site Support & Feedback
  • Settings
TI E2E™ Community Groups
  • TI University Program
  • Make the Switch
  • Microcontroller Projects
  • Motor Drive & Control
Other Communities
  • Deyisupport
  • Designsomething.org
  • beagleboard.org
  • TI on Element 14
  • TI on TechXchangeSM
Other Technical & Support Resources
  • WEBENCH® Design Center
  • Product Information Centers
  • Technical Documents
  • TI Design Network
  • TI Technical Articles
  • TI Training

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
embedded processors, along with software, tools and the industry’s largest sales/support staff.

© Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy Policy | Terms of Use