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.

MSP430 UART RX



Hello,

I do not fully understand the UART functionality. I am trying to keep the MSP in sleep mode for as long as possible. So in case a device sends a UART command to the MSP while it is in LPM (given that the interrupt is disabled), does it disregard the message? Or does it store it in the receive buffer register? In case it does, I see that the register is only 8 bits, so in case two messages were sent, does it get rid of the first one, and only keeps last one? I am new to this. Thanks in advance.

 

Alin

  • The UART input buffer wil hold only hte last received byte. You'll see a buffer overflow flagged if more than one byte has arrived since you last read the input buffer.
    THis is why an interrupt is generated when a byte is received (provided you enabled interrupts).

    On an interrupt, the CPU will be activated from LPM for the duration of your interrupt service routine (ISR). When you leave the ISR, the MSP will fall back into LPM, unless you used a special command that keeps it awake on ISR exit. So teh ISR can read the byte in the input buffer (RXBUF) and send the cpu back to sleep, until all bytes of a command have arrived. Then it will perform the wekaup command und your main function will continue as if there has never been a sleep time and hte commadn has magically appeared.

    On some MSPs, however, there is another option: you can set up a DMA channel that will automatically transfer the incoming byte(s) to a memory array and trigger an interrupt once a certain number of bytes has been received. This will keep the MSP in LPM until all bytes are there.
    But I have no experience with DMA transfers in LPM. since DMA and CPU share the same MCLK signal which is off in LPM and takes some time to come up again.

    Also, there are timing considerations. On 115.2kBd, bytes follow with 8.68µs distance. But waking up from LPM takes 6µs alone, plus the normal ISR entry overhead of ~1µs (depending on MCLK), so on baudrates above 57600Bd, things can get pretty tight when used in conjunction with LPM (and entering LPM does not make much sense anymore)

**Attention** This is a public forum