Pages: [1]   Go Down
Author Topic: Rant: shooting myself into my own foot  (Read 645 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Faraday Member
**
Karma: 24
Posts: 3499
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Argh. This week I created some pretty simple parser + ISR. Of course the first implementation failed. Then I added debug print statements. Sure enough this made things worse. Seems the ISR was causing it. However removing the ISR did not resolve anything. Then I thought maybe the debug prints are a new issue and replaced everything with progmem / print(F("...")). Again uncontrolled crashes.

After two days I finally got it. Nothing at all crashed. However: even outside of ISRs cli() before Serial.print will never succeed. "Obviously" serial requires interrupts to work. So basically my debug code was causing all the issues.

One more lesson learned: combining Serial with cli() is a bad idea.
Logged

Check out my experiments http://blog.blinkenlight.net

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 511
Posts: 19314
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The only thing worse than debugging code making something that used to work, stop working, is when you add debugging code to solve a problem, and the presence of the debugging code makes the problem go away. smiley
Logged

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34725
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That has happened more times than I can remember to other people when I was a manager. Never happened to me though.
Logged

USA
Offline Offline
Sr. Member
****
Karma: 17
Posts: 392
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

... the debugging code makes the problem go away.
Every time I should have said, "volatile."
Logged

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 511
Posts: 19314
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It can be other things. For example in Visual C++ (from memory) if you do a "debug build" static (or auto maybe) variables get initialized in a different way than a "release build". For example, to put something like 0xBADBAD into pointers, so you don't accidentally use them without initializing them. But this very difference can make the code behave differently.
Logged

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Pages: [1]   Go Up
Jump to: