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.

launchpad UART: receiving multiple characters, if no char is received disable rxbuf



i'm trying to receive multiple characters and store them in a char array. but mcu doesn't know how many characters will be received. how to write code to disable UCA0RX interrupt if no characters are received further.

if i know two char will be received i can use "strlen". but when the length of char received is unknown, how to disable UCA0RX interrupt if no char are further received?

for example:

char string1[];

string1[i++] = UCA0RXBUF;

  • Why do u want to disable the uart intr? If u disable it how will u enable it again? U may lose data while ur intr is disabled. U can enter lpm mode instead of disabling intr if ur planning to save power.

  • Well, if oyu disable the RX interrupt (by clearing the UCA0RXIE bit), you can be sure you won't receive more than you already got (at least not by interrupts). it oes nto mean, however, that you got all you wanted.

    In my own 'OS' I implemented a ring buffer that is fuilled by interrupt as data comes in. The getchar funciton hat reads from the ring buffer has a timeout of some ms. So if the getchar function times out, apparently nothing is coming in anymore for the moment.

**Attention** This is a public forum