This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARM:UART Serial comunication on LM3S8962

I am working on LM3S8962 and need to write a program to comunicate with PC via UART. I use Labview inline C node to write codes using ARM_Serial.c which is from Keil Software.

The file has

int ARM_Serial_InitPort (int serDevNo, unsigned long baudrate, unsigned int  databits, unsigned int  parity,   unsigned int  stopbits)
int ARM_Serial_Write (int serDevNo, const char *buffer, int *length)

I tried to use them to control serial port, but it didn't work well. I used U0TX, U0RX and GND pins on micro controller to connect to a serial port in PC.

I couldn't find any information about ARM_Serial_InitPort and ARM_Serial_Write functions on the internet. Any information or tips about it would be very appreciatted.

Thank you.

Masa

Parents Reply Children
  • Yes, it is.

    The header of the c file says

    /*----------------------------------------------------------------------------
     *      Name:    ARM_Serial.c
     *      Purpose: For Luminary Micro LM3SXXXX microcontrollers
     *               adapted from Template generic driver for LabVIEW
     *      Version: v1.00
     *      Note(s):
     *----------------------------------------------------------------------------
     *      This file is part of the uVision/ARM development tools.
     *      This software may only be used under the terms of a valid, current,
     *      end user licence from KEIL for a compatible version of KEIL software
     *      development tools. Nothing else gives you the right to use it.
     *
     *      Copyright (c) 2007 Keil Software.
     *---------------------------------------------------------------------------*/
    

    These codes bellow are test codes I wrote, which doesn't work. Did I make a mistake or do I need to do something else to use serial port?

    //initialize serial port
    int ret;
    ret = ARM_Serial_InitPort(0, 9600, 8, 0, 10);
    printf("initialize-ret:%d",ret);
    
    
    
    //Write data to serial port
    int l = 5;
    int ret;
    char *x;
    x="test";
    ret = ARM_Serial_Write(0, x, &l);
    printf("writing-ret:%d\n",ret);
    

  • So, I guess that's where you need to look for documentation on this?

  • Yes. But I couldn't find any information about it.

    By the way, I noticed that my microcontroller which is connected to PC with USB cable creates a virtual com port in PC. And it seems that the virtual com port is receiving some data from the microcontroller instead of actual serial port.

  • I realized that I forgot to use ARM_Serial_OpenPort to open a serial port. Using the function, now it is communicating via serial port, however, characters get garbled. Is there any mistake?

    int ret;
    // PortNumber, serialDeviceNumber=PortNumber+1
    ret = ARM_Serial_OpenPort(1,2);
    
    //serialDeviceNumber, Baud, DataBits, Parity, StopBits
    ret = ARM_Serial_InitPort(2, 9600, 7, 0, 1);
    
    
    //write data to serial
    int l = 5;
    int ret;
    char *x;
    x="abcd";
    ret = ARM_Serial_Write(2, x, &l);
    
    

  • Did you intend to use 7-bit transfers?

    Have you verified baudrate with an oscilloscope?

  • I tried 7-bid, but It didn't work.

    >Have you verified baudrate with an oscilloscope?
    Not yet. I will check it.

  • You _tried_ 7-bit?

    But your posted code contains:

    ret = ARM_Serial_InitPort(2, 9600, 7, 0, 1);
    


    Isn't that the configuration for 7-bit data?

  • I tried both 7 bit and 8 bit.

    I should have posted the code with 8 bit.