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.

MSP430F5438A: 20bit UART Protocol?

Other Parts Discussed in Thread: MSP430F5438A

Hello all,

I want to send data between two devices with the UART module and my frame would be around 20bit with the start and stop bits. But in the user's manual I can only find the description for sending 8 data bits in a frame. So if I do this in my case, I would need 33bits instead of the 20bits (+4 start/stop bits, +3 parity bits, +6 "frame numbering" bits)

Does anyone know if it is possible to define a 20bit asynchronous UART protocol on MSP430F5438A?

Thx for your help,

Sebastian

  • Sebastian Lenz said:
    Does anyone know if it is possible to define a 20bit asynchronous UART protocol on MSP430F5438A?

    If you have a high enough processing speed to baud rate factor, you can do this by bit-banging the protocol using I/O pins. You can use a timer module to time the transitions for better accuracy.

    The USCI module cannot do the mode you describe.

  • Sebastian Lenz said:
    I want to send data between two devices with the UART module and my frame would be around 20bit with the start and stop bits.

    What are those two devices? Maybe you need SPI, not UART? What bit rate you are looking for? How ofthen those frames shall be sent?

  • USI or USCI are Universal 8-bit communication modules. What you need is a separated 20(32)-bit SPI module, I doubt if MSP430 has such one but in the DSP microcontrollers section you will find them for example TMS320C55x. Maybe C2000 but I believe the maximum here is 16-bit.

  • Ilmars said:

    What are those two devices? Maybe you need SPI, not UART? What bit rate you are looking for? How ofthen those frames shall be sent?

    This two devices are two F5438A but at different locations in hard industrial environment. Because of this environment I want to use UART and RS485. I have a time slot of around 3ms for reading, processing and sending the data. So the longer I need for reading and sending, the shorter the time for processing the data. And this 20 or 33 bit have to be sent 4 times for a complete data package.

    But I was guessing that there is no other possibility then sending the 33bit.

  • RS-485 half duplex or full duplex?

    Do you have control over the data rate at both ends? If so, nothing says that you have to use "standard" baud rates. Up the baud rate to whatever the uC, transceiver, and cabling environment combination will allow with adequate head room.

  • Sebastian Lenz said:
    This two devices are two F5438A but at different locations in hard industrial environment.

    I do not see you can gain much by saving on few start/stop bits, but you can lose a lot. I would go for 8 bits w/o hesitation.

  • Brian Boorman said:

    RS-485 half duplex or full duplex?

    Do you have control over the data rate at both ends? If so, nothing says that you have to use "standard" baud rates. Up the baud rate to whatever the uC, transceiver, and cabling environment combination will allow with adequate head room.

    The RS485 is half duplex. Yes I can control everything at both ends, in principle it should be 2 times the same software with some minor changes, but only one side has this strict timing requirements for data processing.

    Ok, thats a new aspect, that I can adjust the baudrate to non-standard values too. I have to search for it in the datasheet/user's guide. Thx for this hint!

  • So you are in design control of both sides and you are having 20bit data that need to be transferred.
    Send three 8 bit bytes, just as small 4bit waste and you probably could fill in those 4bits with something useful anyway/or as checksum

  • Agreed, why dont you just start with the simplest way of using the UART 8bit send and receive and see if it works fine in your environment.

    If it should be too slow, I would also like to know how you write your own bit banging protocol to send non standart amounts of bits.

  • seb said:
    I would also like to know how you write your own bit banging protocol to send non standart amounts of bits.

    A timer and an ISR-driven software state machine to read/write the GPIO bits. Basically I would model this the same way I would do a custom UART in an FPGA or ASIC (clocked stateful process).

  • If you design both sides and don’t have to obey a predefined protocol, you can do almost everything.
    Rs485 is designed for harsh environment, as it forms a current-loop where polarity of the current flow defines the logical signal level. If properly implemented, it is a very reliable transfer medium.
    Since an RS485-Transceiver is just a dumb TTL->current-loop converter, you can run any signal through it. However, UART is easiest.
    Simply put your data bits into 8 bit frames. You may add a start frame and a stop frame with checksum, stretch the bits with a 4->6 bit lookup table with error correction, do whatever you want to ensure data integrity.
    But whatever you do on the data side, don’t forget that proper bus termination is vital on RS485. (Well, and RS485 is far from being low power. Very far. So it is the wrong way if you run from batteries)

  • Thanks for all your hints and support,

    after reading all this and re-thinking my concept, I think I really will do it with the standard 8bit frames.

    As I have harsh environment, I think I really need RS485 although I also have to save power (Its nearby my limits but still ok). So I need a trade off between power consumption and data ingrity. 

    One more further question:

    Has anyone of you a good source (Book, Website e.g.) that explains programming in layers (ISO-OSI)? 

**Attention** This is a public forum