softSerial stops working with too much code

I am using a Nano to talk to two other Nano(s). One is taking through the Serial port. The other Nano talks through the softSerial port emulation.

All is well, all communication is perfect and messages recieved.

When the source code compiles it give the message at the bottom of the screen that 23% of available space for variables used and 31% of space for program code used.

Yet there seems to be a limit to how much switch-case statements I can have and if statements. When I pass this hidden limit softSerial stopps working. The source code works perfectly, is just the softSerial communications stops.

Has anyone ran into this before?

I have a big switch-case statement with 31 parts, each part does different things. It seems i can REM out any part to restore softSerial functionality: it appears there is a "limit" to how many branches in logic if using the softSerial.

Does this sort of thing sound familiar to anyone?

Thank you in advance.

Without seeing your code I can only guess that it is a heap or a stack issue. Just because it says only 23% of space is used for variables does not mean you won't run out memory either because you exceeded stack space or heap space via dynamic allocation.

All that depends of how you are passing variables, how deep your call stack goes, or any other memory allocation (like using String).

It might be helpful to see your sketches.

Only a tiny fraction of people know what REM'ing out is (commenting out). For such an issue (actually almost any issue), it is almost mandatory for you to post your entire code. Generic solutions for such problems really don't exist.

What puzzles me the most is ALL the IF and CASE statements work perfectly, its just the the software emulation port (softSerial) dies with too many CASE statements (I have about 30). I can comment out any 5 at random and then softSerial runs perfectly again (along with the remaining 25 CASE statements). Will try to post the code once I clean it up

What puzzles me the most is …

What puzzles me is why you have not posted your program.

How can you expect people to help you when they can’t see your code?


At work now. When I get home today or tomm I will clean it up and post it