32U4 Programing issue

I have been developing a control system using several Pro Micros, one Micro (both using 5V ATmega 34u4) and 1 Mega2560 R3s. The Pro Micros (32u4) work fine as i2c slave keypad CPUs, no issues here. One Mega2560 is the master and drives most of the drivers in that area. Everything works well with an exception I have not been able to grasp. The only Micro (also 32u4 with a few more pins accessible) in the system, is used as a slave to control some drivers in its area When I have added 2 simple functions to the code in the Micro, it locks up, even refusing to be recognized by the USB port on my Mac. I can reset and load the code, but as soon as its loaded, the USB connection disappears and obviously Serial.print cannot provide any clues as to why it stopped. Strangely this same code runs flawlessly in a 2560, and it does not appear that I am close to the capacity of the 34u4 as my code is 21,800 of 32k in size Any ideas as to what may be happening? Thanks

Hi Jerry

Strangely this same code runs flawlessly in a 2560, and it does not appear that I am close to the capacity of the 34u4 as my code is 21,800 of 32k in size

Could the program be running out of SRAM rather than flash memory? The Mega 2560 has 8KB, more than the Micro, I think.

Maybe you could post your code for people to review?

Regards

Ray

I see, the 2560 has 8K and the 32u4 2.5k

Is there a simple way to get a report on SRAM usage in a script?

Is there a simple way to get a report on SRAM usage in a script?

http://playground.arduino.cc/Code/AvailableMemory

Keep in mind that memory use changes with every function called.

Thanks so much! Ill check it out and let you know what i find.

Thank you so much Hackscribble!

That was exactly the issue and was easily observed and fixed using freeRam()

I greatly appreciate your help!