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

Memory problem with msp430g2553

$
0
0

Hi! I tried to connect GPRS Shield from Arduino to msp430g2553 with SoftwareSerial library. But I faced with the problem. When the size of sketch exceeds 5590 bytes, global variables do not work. I just add one variable (global string) and the program stops executed correctly.

Here is the code:

/*
  When new serial data arrives, this sketch adds it to a String.
  When a '!' character is received, the loop prints the string "Hello world!"
*/

#include <SoftwareSerial.h>
SoftwareSerial mySerial(P2_0, P1_5);

String inputString = "";           // a string to hold incoming data
boolean stringComplete = false;    // whether the string is complete

String string1 = "Hello ";
String string2 = "Just string";
String string3 = "Another string";
//String string4 = "Another string";  // If we uncomment this line, code will not work :( 

void setup()
{
  Serial.begin(9600);
  mySerial.begin(19200);
}

void loop()
{
  if (stringComplete)  //if the incoming character is a '!'
  {  
  inputString = "";
  stringComplete = false;
  Serial.print(string1);
  Serial.println("world!");
  }
}

/*
  SerialEvent occurs whenever a new data comes in the
  hardware serial RX. This routine is run between each
  time loop() runs, so using delay inside loop can delay
  response. Multiple bytes of data may be available.
*/
void serialEvent() 
{
  while (Serial.available()) 
  {
    char inChar = (char)Serial.read(); 
    inputString += inChar;
    if (inChar == '!') { stringComplete = true; } 
  }
}

Somebody knows where is my problem?

Attached Files


Viewing all articles
Browse latest Browse all 2077

Trending Articles