Go Down

Topic: Strange memory problem? (Read 298 times) previous topic - next topic


Jun 11, 2015, 05:08 am Last Edit: Jun 11, 2015, 05:09 am by Qdeathstar
I'm not sure if it was a memory problem, but today I was having an issue where my TLC5940 would apparently get cleared (all of the LEDS connected to it would turn off) when my menu was being drawn onto an LCD screen.

However, the arduino didn't reset or hang... the rest of the program ran normally (accepting inputs, changing menus, displaying the time via a DS1307, ect)....

I am using about 64% of the arduino's SRAM for this program (according to the IDE), leaving around 3kb left for memory used in functions..

I was able to narrow the problem down further to a "splash screen" that is kind of like a screen saver that runs when no buttons have been pressed. That code is below:

Code: [Select]

void screen() {
  static boolean once;

  if (AoldMinute != minute || zoneSetup > 0) {
    AoldMinute = minute;
    once = 1;

  //these lines turn off or on any button LED, depending on its previous state. If the led was off before (blinking as a value of 2), it will
  //be off now, if the led was on (blinking as a value of 3), the LED will be on now.
  for (byte n = 0 + zoneMod; n < 4 + zoneMod; n++) {
    switch (ledAction[n])
      case 2: // blinking but was off before it was blinking
        ledAction[n] = 0; //lets turn it off again
      case 3: // blinking but was on before it was blinking
        ledAction[n] = 1; //lets turn it on again
  zoneSetup = 0;    //setting soneSetup to zero, lets us no that no zone is active, therefore no changes can be made.
  lcd.setCursor(0, 0);
  if (once) {
    once = 0;
    if (month < 10) {
      lcd.print(month, DEC);
    } else lcd.print(month, DEC);
    if (day < 10) {
      lcd.print(day, DEC);
    } else lcd.print(day, DEC);
    lcd.print(year, DEC);
    lcd.print(F("  "));
    if (hour < 10) {
      lcd.print(F(" "));
    lcd.print(hour, DEC);
    if (minute < 10) {
      lcd.print(minute, DEC);
    } else lcd.print(minute, DEC);
    lcd.print(" ");
    if (PMflag == 1) {
    } else {
  lcd.setCursor(0, 1);
  lcd.print(F("   Awaiting Input   "));
  lcd.setCursor(0, 2);
  lcd.print(F(" Use Buttons Below  "));
  lcd.setCursor(0, 3);
  lcd.print(1 + zoneMod);
  lcd.print(F("     "));
  lcd.print(2 + zoneMod);
  lcd.print(F("      "));
  lcd.print(3 + zoneMod);
  lcd.print(F("     "));
  lcd.print(4 + zoneMod);

Originally, I didn't have the F() macros, but after I added them my program works fine (and the LED doesn't turn off)...

I thought an arduino out of memory would reset? Is that wrong... or was there some other issue with my program. I've attached the whole thing below... but its a huge program...

A creaking creeping shadow
stiff against the freezing fog
glares at a tickless watch.

Time has failed him -- all things shall pass.


I thought an arduino out of memory would reset?
It might do, but there's no guarantee.


The usual symptoms of memory exhaustion are "anything can happen"
[ I DO NOT respond to personal messages, I WILL delete them unread, use the forum please ]

Go Up