Other Parts Discussed in Thread: MSP430G2553
//START OF CODE 1
SendString("ATE0\r\n");
i=0;
do {
while(!(IFG2&UCA0RXIFG));
Received [i] = UCA0RXBUF;
i++;
} while (Received [i-1] != 'K');
// END of CODE 1
//START OF CODE 2
while(!(IFG2&UCA0RXIFG));
Received [0] = UCA0RXBUF;
while(!(IFG2&UCA0RXIFG));
Received [1] = UCA0RXBUF;
while(!(IFG2&UCA0RXIFG));
Received [2] = UCA0RXBUF;
while(!(IFG2&UCA0RXIFG));
Received [3] = UCA0RXBUF;
while(!(IFG2&UCA0RXIFG));
Received [4] = UCA0RXBUF;
while(!(IFG2&UCA0RXIFG));
Received [5] = UCA0RXBUF;
*/
//END OF CODE 2
Im using the following two segments of code ( CODE 1 and CODE 2) to capture UART characters coming out of SIM908 ( a GSM MODULE) . The code 2 works perfectly! however the CODE 1 does. Im wondering why and I cant seem to figure why.
I am using MSP430G2553. In the First Code ( the one that doest work), the character array ‘Received [ ]’ gets nothing. Is this possible? But it somehow passes the check “while (Received [i-1] != 'K');” and goes to the next execution point in debugging and I know for a fact that DO WHILE loop is executed.
I don’t like Code 2 because it’s not so professional. It also would use up 100 lines of code to receive 50 characters. So I would like to know a way to improve the UART Receiving code. Has anyone got a better approach to receive UART characters using MSP430G2553? And no, I don’t want to use Interrupts, because I will have to be calling delays till my character array gets filled and I believe it’s not important in my application to go to sleep in-between receiving two characters.
Your responses would be appreciated so much.