Go Down

Topic: Memory issue? (Read 1 time) previous topic - next topic

pjchant


Link is broken/incomplete


Sorry, I'm an idiot, that link was to the off-line (dev) version of my website.  Correct link is:

http://www.petezilla.co.uk/public/embedded/arduino/morse

Specifically:

http://www.petezilla.co.uk/public/embedded/arduino/morse/morse7.pde

Graynomad

With the code commented out

text    data     bss     dec     hex filename
9656     760     201   10617    2979 blink.cpp.elf

with code included

text    data     bss     dec     hex filename
9860    1550     201   11611    2d5b blink.cpp.elf

That's 1751 bytes of RAM used not counting the stack. It's getting in the dodgy area.

Try just removing a few lines to see if that fixes the probem.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

pjchant


If you have any large tables that aren't defined as being in PROGMEM, then they will use RAM.


I have used a number of strings, using the string object.   They are not especially large, but on the other hand there is not a lot of SRAM.  The code I comment out to make things work is in the serial routines, with fixed strings.

Given that my variables are altered during the course of running the program it would not be a good idea to use PROGMEM I would have thought.   I wonder however whether putting the help information below into a variable stored in program memory might help.  Another solution, probably the best, would be to put it into the EEPROM.  However, I'm not sure if there is a way that data could be included in the sketch.  I assume I'd have to upload it separately.  

However, I'm assuming it is a memory issue - am I right?

Routine below:

Code: [Select]
void help() {
 Serial.println("~");
 Serial.println("~USB ASCII to Morse converter.");
 Serial.println("~");
 Serial.println("~Help:");
 Serial.println("~ ##H: Print help (upper case H).");
 Serial.println("~ ##1: Rate 5 words per minute");
 Serial.println("~ ##2: Rate 10 words per minute");
 Serial.println("~ ##3: Rate 15 words per minute");
 Serial.println("~ ##4: Rate 20 words per minute");
 Serial.println("~ ##5: Rate 40 words per minute");
 
 
 /*
 If the following is not commented out then the arduino produces no
 output.
 */
 
 /*
 Serial.println("~");
 Serial.println("~Add # to the end of a line to repeat message.");
 Serial.println("~A # before any letter omits spaces to they can be run-");
 Serial.println("~together to generate prosigns, e.g. #CT (start of message).");
 Serial.println("~Carriage return (13) causes message to be transmitted.");
 Serial.println("~");
 Serial.println("~Commands and Messages:");
 Serial.println("~Lines beginning in tilde ~ are information");
 Serial.println("~Prompt for user input is >");
 Serial.println("~Messages:");
 Serial.println("~    <Ready    =    Awaiting commands or data.");
 Serial.println("~    <Sending  =    Sending morse.");
 Serial.println("~    <Wait     =    Please do not send data, buffers near full.");
 Serial.println("~    <Overrun  =    Too much information in buffers.  Contents ");
 Serial.println("~                   deleted without being sent.  Send data again");
 Serial.println("~                   in smaller chunks.");
 Serial.println("~");
 Serial.println("~Basic idea is you send data, when a <Wait is received then");
 Serial.println("~continue passing current word then hit return to send chunk");
 Serial.println("~before sending more data.");
 Serial.println("");
 */
 
 
}

pjchant


With the code commented out

text    data     bss     dec     hex filename
9656     760     201   10617    2979 blink.cpp.elf

with code included

text    data     bss     dec     hex filename
9860    1550     201   11611    2d5b blink.cpp.elf

That's 1751 bytes of RAM used not counting the stack. It's getting in the dodgy area.

Try just removing a few lines to see if that fixes the probem.

______
Rob



Interesting, with the help commented out as below I can send 10 characters but with 20 it hangs.  I suspect that this is it running out of memory - perhaps a buffer over-run type problem, not that I have a fixed length buffer, but I do have finite ram.

Code: [Select]
void help() {
  Serial.println("~");
  Serial.println("~USB ASCII to Morse converter.");
  Serial.println("~");
  Serial.println("~Help:");
  Serial.println("~ ##H: Print help (upper case H).");
  Serial.println("~ ##1: Rate 5 words per minute");
  Serial.println("~ ##2: Rate 10 words per minute");
  Serial.println("~ ##3: Rate 15 words per minute");
  Serial.println("~ ##4: Rate 20 words per minute");
  Serial.println("~ ##5: Rate 40 words per minute");
 
 
  /*
  If the following is not commented out then the arduino produces no
  output.
  */
 
 
  Serial.println("~");
  Serial.println("~Add # to the end of a line to repeat message.");
  Serial.println("~A # before any letter omits spaces to they can be run-");
  Serial.println("~together to generate prosigns, e.g. #CT (start of message).");
  Serial.println("~Carriage return (13) causes message to be transmitted.");
  Serial.println("~");
  Serial.println("~Commands and Messages:");
  Serial.println("~Lines beginning in tilde ~ are information");
  Serial.println("~Prompt for user input is >");
 
  /*
 
  Serial.println("~Messages:");
  Serial.println("~    <Ready    =    Awaiting commands or data.");
  Serial.println("~    <Sending  =    Sending morse.");
  Serial.println("~    <Wait     =    Please do not send data, buffers near full.");
  Serial.println("~    <Overrun  =    Too much information in buffers.  Contents ");
  Serial.println("~                   deleted without being sent.  Send data again");
  Serial.println("~                   in smaller chunks.");
 
 
 
  Serial.println("~");
  Serial.println("~Basic idea is you send data, when a <Wait is received then");
  Serial.println("~continue passing current word then hit return to send chunk");
  Serial.println("~before sending more data.");
  Serial.println("");
  */
 
 
}

James C4S


If so, you can see in the bottom of the screen how large your sketch is and how much memory available is.


This is not the case.  This message is the amount of Flash (or program) storage being used and what is left.  It has nothing to do with the RAM at Runtime.

It is entirely possible to have a sketch that takes up 15k of Flash/Program Memory and only use a couple hundred bytes of RAM. 
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Go Up