Pages: [1]   Go Down
Author Topic: Rant: shooting myself into my own foot  (Read 631 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Faraday Member
**
Karma: 24
Posts: 3495
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
Offline Offline
Brattain Member
*****
Karma: 497
Posts: 19051
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


Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 34519
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: 386
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
Offline Offline
Brattain Member
*****
Karma: 497
Posts: 19051
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


Pages: [1]   Go Up
Jump to: