0

Also posted at: https://forum.arduino.cc/index.php?topic=549672.0

is there anyone who experienced similar problem or knows a solution to it?

The problem is that after uploading the code Arduino Pro Micro hangs (and RX led is constantly on).

The problem occurs instantly after turning on the microcontroller even if I put "delay(10000);" at the begining of the code trying to see at which point the error occurs.

The problem can be "fixed" by adding 'Serial.print("aa");' at random place within the code... Which results in the following output during upload:

Sketch uses 18318 bytes (63%) of program storage space. Maximum is 28672 bytes.
Global variables use 1814 bytes (70%) of dynamic memory, leaving 746 bytes for local variables. Maximum is 2560 bytes.

Suprisingly, using 'Serial.print("a");" instead does not fix the problem. It results in the following output during upload:

Sketch uses 18314 bytes (63%) of program storage space. Maximum is 28672 bytes.
Global variables use 1810 bytes (70%) of dynamic memory, leaving 750 bytes for local variables. Maximum is 2560 bytes.

It seems very weird to me that adding serial print instruction with certain length (at seemingly random place) can solve such problem...

Another circumstance which seems to be solving the problem is commenting out one of the 2 lines (does not matter which):

sprintf(at_cmd, "AT+NAME%s\0", bluetoothName);
sprintf(at_pin_cmd, "AT+PIN%s\0", pin);

It's a spaghetti code so I doubt anyone will analyse it but just in case if anyone wanted to check it for some more or less obvious characteristic (e.g. F()/eeprom/memory extensive use or something...) then here it is: Hastebin - link

I'm using "Arduino Pro Micro 5V" and Arduino IDE 1.8.5 with "Arduino Leonardo" board setting

  • You should make more use of PROGMEM for your string constants. Use the _P variants of the string library functions. – Majenko May 26 '18 at 14:02
  • You may want to look up how to use PROGMEM, That will let you move your arrays and global string literals to program space instead of taking up RAM – ratchet freak May 26 '18 at 14:03
  • Does the only occur after uploading a new sketch or also after pressing the reset button or power-cycling? – Gerben May 26 '18 at 14:11
  • Thanks for suggestion, but what do you guys think about the potential cause of the problem which I described? – monday May 26 '18 at 14:12
  • 1
    Also asked here: forum.arduino.cc/index.php?topic=549672.0 – Jot May 26 '18 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.