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/MSP430FR5994: Remove a character from UART stream

Part Number: MSP430FR5994

Tool/software: Code Composer Studio

Hello,

I have connected my MSP430FR5994-LP to a sensor which can send data via UART. As mentioned in its datasheet "The output is an ASCII capital “R”, followed by four ASCII character digits representing the range in millimeters, followed by a carriage return (ASCII 13)." I have tested it, I receive an "R"when i acquire the data. How can I remove letter "R" from it? Can I use the remaining information to do some averaging on it?

Regards,

Prudhvi Sagar

  • Hello Prudhvi,

    The data you received from the sensor via UART will be stored in UART RX buffer and you need to move the data from RX buffer into the location you want to store. After that you can just remove the first and last byte of the package.

    Thanks,
    Yiding
  • Hello,
    Im new to hardware programming. Can you suggest me how to remove a specifc byte? Some tutorials to do bit wise operations.

    Regards,
    Prudhvi Sagar
  • Hi Prudhvi

    You shouldn't need to do any bit-wise operations.  When the message travels into the device's UART, an interrupt should trigger to indicate that a byte was received, and that byte will be stored in the receive buffer register (most likely UCA0RXBUF).  Inside that interrupt, I suggest copying the contents of the receive buffer register, which will be a single byte, to an separate array for data processing.  You can also examine the contents of the receive buffer to check whether it contains a number, or the 'R' or carriage return you mentioned, and include/exclude them into that separate array as you like.

    Nate

  • Assuming you have an array with all the characters, char array = "R1234\n\0", you can get an integer by using:

    long strtol(array[1], NULL, 10)

    this is in stdlib.h

    Note that this is a general C question and has nothing to do with the MSP430, per se.

**Attention** This is a public forum