Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

Problem with Serial.available()

$
0
0

Hi,

 

I'm new to energia, and facing a problem with Serial.available(); My problem is by using Serial Monitor of Energia i'm sending a 32 length string to the MSP430 UART. It is storing only 16 characters and terminating. Can you guide what's the problem here?

 

Following is my code:

 

#include <LiquidCrystal.h>
 
LiquidCrystal lcd(P2_0,P2_1,P2_2,P2_3,P2_4,P2_5);
int i=0;
char ch[50];
 
void setup()
{
  // put your setup code here, to run once:
  Serial.begin(9600);
  lcd.begin(16,2);
  lcd.print("MADHU");
  delay(1000);
  lcd.clear();
}
 
void loop()
{
  // put your main code here, to run repeatedly:
  begin:
  
  while(Serial.available()>0)
  {
    ch[i]=Serial.read();
    lcd.write(ch[i]);
    Serial.write(ch[i]);
    i++;
    delay(1000);
    lcd.clear();
  }
  
  ch[i]='\0';
  Serial.print(ch);
  goto begin;
}

Viewing all articles
Browse latest Browse all 2077

Trending Articles