danielhuber 2 Posted February 3, 2016 Share Posted February 3, 2016 I am running an MSP-EXP430G2 Lauchpad with an MSP430G2553 on Windows 7. The following code: ============================ #include <IRremote.h> String st; void setup() { Serial.begin(9600); st=String(); } void loop() { st=st+'2'; Serial.println(st); delay(200); } =============== produces following output: 2 22 222 2222 22222 222222 2222222 22222222 222222222 2222222222 22222222222 222222222222 2222222222222 22222222222222 222222222222222 2222222222222222 22222222222222222 222222222222222222 2222222222222222222 2 22 222 2222 ..... After a string length of 19 the string is cleared. Why? When exactly this happens depends also on additional code. With a MPU with lesser RAM I would guess that the RAM overflows, but 0.5kB of the MSP430G2553 should be large enough. Has anybody an explanation? cheers, Daniel Quote Link to post Share on other sites
roadrunner84 466 Posted February 3, 2016 Share Posted February 3, 2016 Because String does use dynamic memory, which your MSP430 does barely handle. Either declare your string with a decent size, or use plain c-strings. String st(100, '\0'); or char st[100] = ""; energia 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.