Sketch does not always accept reset

NANO EVERY:
Hello, I am working on two separate sketches. One always resets when an upload completes and also always immediately with the reset button. The other sometimes will and sometimes wont.

When it doesn't work first time a lot of presses on reset will eventually work, sometimes I press more than 20 times and then it works. Sometimes an upload resets and sometimes not, maybe about 50/50, however, the upload always works, i.e. when I eventually succeed in resetting, the new uploaded version is present.

My sketches are very large, so I wont be posting them in entirety.

Can anyone recommend something I should investigate?

I am using SSD1306 OLED display and also some other I2C devices. I am using interrupts in both sketches. Structurally they are similar with similar include files. I have not used more than 80% of flash or 25% of RAM.

How can I find out if there is a memory leak?

thank you in advance for any suggestions,
Adam Bennette

one approach in this "desperate" case is the start with the working code and step by step try to translate it into the other code. of course this is difficult and tedious

divide and conquer -- do half the changes. if the problem persists, is more likely the problem is within those changes so remove half of those changes, and so on

Hi Greg, yes, I have had to do that before, and it's a pain.
The thing I don't get is that the reset button forces the CPU to a vector in ROM, so no code of any kind should be able to interfere with basic hardware reset, but it does. Maybe the Arduino O/S, if you can call it that, vectors Reset via a RAM pointer it has setup and I am writing trash to that address somehow. However, if that were true then it would never rest again and it does, after a lot of presses - or several uploads.

Thank you for the prompt reply.

Adam

try a print near the top of setup() with a long delay to verify the start of the code

As far as I know, it is not possible to run a program that would inhibit the action of the hardware reset.

That would kinda defeat the purpose of having it.

In addition to the report of the compiler, memory may be needed for your displays, which the compiklr doesn't know about.

Put some printing into the mix and move that along in the code - I feel sure you are getting into setup(), and very soon after that getting into trouble.

Last one I saw was a missing begin() method call, sketch freaked out right away I did something with the uninitiated object.

a7

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.