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.

CCS/RM57L843: Receiving data through UART

Part Number: RM57L843
Other Parts Discussed in Thread: HALCOGEN

Tool/software: Code Composer Studio

Hello all,
Pleas, I have problems setting the UART for receiving, I followed the examples but still not working. I did the following:
Using HALGOGEN:
1. Enable SCI1 driver
2.Configure SCI , just setting the baud rate and stop and start bit, I don't know if i should configure more than that, unfortunately the examples are NOT clear.
3. Generating the code.

In CCS, I edited the code as follow:

//--------------------------------------------------------------------------------------------------------------------------------------
/* Include Files */

#include "HL_sys_common.h"
#include "HL_system.h"

/* USER CODE BEGIN (1) */
#include "HL_sci.h"

#define  Size 7
// send the following
uint8  T_Data[Size]= {'C','M','I','Y','C',' ',' '};
//store the received data
uint8 R_Data[Size];

// function prototype
void sciDisplayText(sciBASE_t *sci, uint8 *text, uint32 length);
void wait(uint32 time);

//choosing UART1
#define UART sciREG1

/* USER CODE END */

void main(void)
{
/* USER CODE BEGIN (3) */
    sciInit();      /* initialize sci/sci-lin    */
                    /* even parity , 2 stop bits */
    sciDisplayText(UART,&T_Data[0],Size);   /* send text code 1 */

    while(1)        /* continious desplay        */
   {
    };

/* USER CODE END */
}

/* USER CODE BEGIN (4) */
void sciDisplayText(sciBASE_t *sci, uint8 *text,uint32 length)
{
    while(length--)
    {
        while ((UART->FLR & 0x4) == 4); /* wait until busy */
        sciSendByte(UART,*text++);      /* send out text letter by letter   */
        wait(200);
        sciReceive(UART, 1, &R_Data[length]);
    };
}


void wait(uint32 time)
{
    time--;
}
/* USER CODE END */
//----------------------------------------------------------------------------------------------------

basically, the T_Data is sent via sciSendByte(UART,*text++); and it is displayed on the terminal
I need the sciReceive(UART, 1, &R_Data[length]); to store the data in R_Data, which I couldn't make it happen

Is my mistake in the configuration part, or in the code part??, I ran out of ideas.. Thank you

  • Hello Moud,

    I see that you have an array for sending data to the terminal window and this seems to be working for you. Where do you expect to receive data from? Are you receiving data through the terminal window as well? i.e., are you entering data in the terminal window via the keyboard? Often how this is done is by a mirror operation. i.e., a key is pressed as input, the character is received by the controller, the received letter is then transmitted to the terminal window (i.e., received data is mirrored to the transmit to the terminal window for display). Note that just because the data Tx'ed is displayed on the terminal window doesn't mean it will be sent by the terminal window to the development board via UART.
  • Hello, this is a tutorial in Spanish but you can follow the steps for UART configuration.

    regards

  • Dear Chuck Davenport,
    Thanks for your reply, I have two situations
    1. Either by sending PIN via keyboard
    2. or I have a GUI (written in Java) that sends a PIN which I need to receive it.
    I couldn't make it work for both cases.
    Would you please tell me which functions i need to use to do whatyou described as mirror operation??
    thanks
  • thanks Martin I'll watch it
  •  

    Hello, here is an example for the RM57 version, in which you receive the data through the UART using interrupts and at the same time reads an ADC channel and sends it through the UART port.

    I hope it's usefull.

    7282.RM57_SCI_DMA.rar

    Regards

    Martin 

  • Hello Moud,

    Since it has been a while since I have been able to visit this post, can you provide an update on where you stand? Is the issue resolved or are you still experiencing a receive issue? If receiving data directly from the PC are you are going through the virtual COM port on the Launchpad or have you used an SCI that to directly connect to the PC port? If the latter, there may be some level shifting issues.
  • Hi, I would like to know if you can implement the example code?
  • I managed to implement the code and now whatever I send from the keyboard i can see it on the terminal and this is half of my goal, the problem I'm facing now is that I have a GUI running on eclipse that sends a PIN which I need to receive it through the UART of my RM57L843 board that I couldn't manage so far. I'm connecting to the board using the usb cable . this is the code

    //-------------------------------------------------------------------------------------------
    /*
    * Serial Communication via UART 1
    * The program receive letter from keyboard and display it on terminal.
    * Stop bit : 1
    * Data bit : 8
    * Parity bit : None
    * Stop bit : 2
    *
    * HalCoGen steps:
    * 1. From TMS570Lxx /RMx -> Enable Drivers unmark all drivers except SCI1
    * 2. From SCI
    * 2.1 activate receive interrupt
    * 2.2 Set the stop bit, start bit ...
    * 3. From VIM 0 - 31 channel activate channel 13
    * 4. Generate the code
    * 5. Jump to CCS
    */
    /* USER CODE BEGIN (0) */
    #include "HL_sci.h"
    /* USER CODE END */

    /* Include Files */

    #include "HL_sys_common.h"
    #include "HL_system.h"

    /* USER CODE BEGIN (1) */
    static unsigned char ReceivedData;
    #define UART sciREG1
    /* USER CODE END */


    /* USER CODE BEGIN (2) */
    /* USER CODE END */

    int main(void)
    {
    /* USER CODE BEGIN (3) */
    //enable IRQ interrupt
    _enable_IRQ();
    //Initialize the sci
    sciInit();
    //sending text
    sciSend(UART, 10, (unsigned char *)"Enter PIN \r \n");

    //Store the received data in ReceivedData
    sciReceive(UART, 1, (unsigned char *)&ReceivedData);

    //run forever
    while(1);
    /* USER CODE END */

    return 0;
    }


    /* USER CODE BEGIN (4) */
    void sciNotification(sciBASE_t *sci, uint32 flags)
    {
    /* enter user code between the USER CODE BEGIN and USER CODE END. */
    /* USER CODE BEGIN (32) */
    sciSend(sci, 1, (unsigned char *) &ReceivedData);

    sciReceive(sci, 1, (unsigned char *) &ReceivedData);
    /* USER CODE END */
    }

    void esmGroup1Notification(int bit)
    {
    /* enter user code between the USER CODE BEGIN and USER CODE END. */
    /* USER CODE BEGIN (1) */
    return;
    /* USER CODE END */
    }

    void esmGroup2Notification(int bit)
    {
    /* enter user code between the USER CODE BEGIN and USER CODE END. */
    /* USER CODE BEGIN (3) */
    return;
    /* USER CODE END */
    }
    /* USER CODE END */
    //----------------------------------------------------------------------------------------------
  • hello Davenport

    I managed to implement the code and now whatever I send from the keyboard i can see it on the terminal and this is half of my goal, the problem I'm facing now is that I have a GUI running on eclipse that sends a PIN which I need to receive it through the UART of my RM57L843 board that I couldn't manage so far. I'm connecting to the board using the usb cable . this is the code

    //-------------------------------------------------------------------------------------------
    /*
    * Serial Communication via UART 1
    * The program receive letter from keyboard and display it on terminal.
    * Stop bit : 1
    * Data bit : 8
    * Parity bit : None
    * Stop bit : 2
    *
    * HalCoGen steps:
    * 1. From TMS570Lxx /RMx -> Enable Drivers unmark all drivers except SCI1
    * 2. From SCI
    * 2.1 activate receive interrupt
    * 2.2 Set the stop bit, start bit ...
    * 3. From VIM 0 - 31 channel activate channel 13
    * 4. Generate the code
    * 5. Jump to CCS
    */
    /* USER CODE BEGIN (0) */
    #include "HL_sci.h"
    /* USER CODE END */

    /* Include Files */

    #include "HL_sys_common.h"
    #include "HL_system.h"

    /* USER CODE BEGIN (1) */
    static unsigned char ReceivedData;
    #define UART sciREG1
    /* USER CODE END */


    /* USER CODE BEGIN (2) */
    /* USER CODE END */

    int main(void)
    {
    /* USER CODE BEGIN (3) */
    //enable IRQ interrupt
    _enable_IRQ();
    //Initialize the sci
    sciInit();
    //sending text
    sciSend(UART, 10, (unsigned char *)"Enter PIN \r \n");

    //Store the received data in ReceivedData
    sciReceive(UART, 1, (unsigned char *)&ReceivedData);

    //run forever
    while(1);
    /* USER CODE END */

    return 0;
    }


    /* USER CODE BEGIN (4) */
    void sciNotification(sciBASE_t *sci, uint32 flags)
    {
    /* enter user code between the USER CODE BEGIN and USER CODE END. */
    /* USER CODE BEGIN (32) */
    sciSend(sci, 1, (unsigned char *) &ReceivedData);

    sciReceive(sci, 1, (unsigned char *) &ReceivedData);
    /* USER CODE END */
    }

    void esmGroup1Notification(int bit)
    {
    /* enter user code between the USER CODE BEGIN and USER CODE END. */
    /* USER CODE BEGIN (1) */
    return;
    /* USER CODE END */
    }

    void esmGroup2Notification(int bit)
    {
    /* enter user code between the USER CODE BEGIN and USER CODE END. */
    /* USER CODE BEGIN (3) */
    return;
    /* USER CODE END */
    }
    /* USER CODE END */
    //----------------------------------------------------------------------------------------------
  • Miquel,

    If the USB is being used in UART mode and is the same as was used with the console interface, then the same code should work. Can you check to see if the there is data coming to the UART RX pin on the board? Are you able to capture a full word on a scope to be sure the data is serial data? My fear is that your GUI in eclipse is actually using a USB protocol not UART. This is a completely different issue and set of challenges especially since the RM57 doesn't have a USB port.
  • Hello Chuck,

    For the GUI code, a library for serial communication has been used where we could specify the required setting for the transmitted data, then we tested it with Arduino board and we could communicate with the board. When we run the GUI we choose the com port first which is the same come the RM57 board uses, is it possible that both are competing for the com port?

    thank you

    Sincerely
    Moud
  • If you present this type of problems, you could try another SCI module, like the SCI3 and a TTL to USB converter, so you would have a dedicated serial communication port.
    RegardS
  • There is most likely not an issue with the COM port configuration, but you could have a look at your device manager and you should see the virtual com port setup in the list of devices. Additionally, if this was working with the terminal window, the issue lies within the GUI and how it is configuring and sending data and is no longer an MCU issue. Seems the MCU is working fine in this case so you need to check the output from the eclipse based GUI at the port to the Launchpad/EVM. If the data isn't there, then it is an exercise to debug the PC SW.

    Can you check with an oscilloscope if data is coming in on the RX line to the MCU? Can you check if there are any Rx errors such as parity errors, data overrun errors, framing errors, etc.