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.

Msp430fg438 Uart programmation

Other Parts Discussed in Thread: MSP430FG438

Hello to everyone,

I'm new of the MCU's world so I wonder if you can help me on this topic. For my graduation paper on aerospace engeneer i'm developing a test board for space solar cells with an msp430fg438. The purpose is to get th voltage from each cell and send this data via UART. I have developed the code to acquire the data from the adc channels, what i' having trouble doing is to set the uart to send the data to the computer. I'm using an ADC12 channel, and I've read around that the uart is just 8 bit so you can loss some data in the process. Can you help me?

Thank you very much

Antonio Ceci

  • Uart effectively send 8 bit at a time, but is this really a limitation?

  • Why do you say that?

    I have a code where I store the result of seven ADC conversions ( int type ) and I send these data by serial port to PC without problems, all this at 115200. If you are receiving strange characters in your terminal, take into account that the data send it by serial port have ASCII format, so you have to convert the ADC values to ASCII.

    Best regards.

  • When you use UART to send data, you give it eight bits (one byte) at a time. When it finishes sending those eight bits, it will notify you and you can give it another eight bits. Time permits,  there is no limit on the total number of bits you can send.

    If you want to send the raw reading of the ADC12, you can send 8 of the 12 bits first, and pad the remaining 4 bits into 8 bits and send that next. This is a little wasteful in time and energy. A more efficient way is to pack two ADC12 readings into 3 consecutive 8-bit bytes to send over the UART. (2 * 12 = 3 * 8).

  • Is T da S said:
    take into account that the data sent by serial port have ASCII format

    Not at all!!

    The data sent/received by a serial port is just bytes:  the serial port neither knows nor cares anything of the meaning of those bytes[1] - it is only the receiving program that interprets them as ASCII or whatever.

    [1] The exception being if the port is using software (XON/XOFF) flow control...

  • Well,it is my fault. I am thinking on my code, and once I have captured the ADC values and done the conversion, I pass this values to ASCII code to check it in Putty terminal. I do not take in account that  maybe he only wants to log ADC values in a file in original format.

    Sorry for the possible confusions.

  • What you have to do is to write a small communication protocol between your sub-systems and main data handler module.

    You're working for aerospace so you have many constraints (I work on a cubesat for my graduation) the first thing to do is to write a tradeoff with all the parameters (bus power consumption, communnication speed, communication reliability, error correction...). With this document you have the basical input to apprehend the requirement.

    The logical aspect has to be taken into account, did the main system has to know which solar cell has the corresponding voltage for example, some time stamping, some flag for different aspect of your power cell (status, health, error...) so your main systeme didn't have to handle those apects.

    Now you could really write what you have to do, and begin to think on how to implement the protocol, which will look like  "information on data" and "data itself".

    Finally the hardware aspect will be simple you have to break the frame into byte and will have something like  "header byte - data1 byte - data2 byte - correction byte" or anything else.

  • Is T da S said:
    I pass this values to ASCII code to check it in Putty terminal

    Of course, an advantage of using ASCII is that you can check it on any basic terminal!

**Attention** This is a public forum