Re: My greatest programming fault - Interrupts [OT] Message #7 Posted by Marcus von Cube on 3 May 2005, 2:52 a.m., in response to message #6 by Wayne Brown
I started my career as a programmer of microprocessor controlled communication devices. This was in the eighties and communication meant serial interfaces.
We had an application that interfaced injection molding machines to a central computer system. The operator could watch the display contents of the machine on the screen in his office. We'd installed the hard- and software at a SIEMENS manufacturing site and were proudly presenting the feature to the SIEMENS staff...
...when I recognized that the screen read ESIMENS instead of SIEMENS.
I was smiling because I was pretty sure the typo could be seen on the machine as well and not only on the central computer. Of course I was wrong!
What had happend?
The UART interface (Z80-SIO) had a small buffer for incoming characters. The Interrupt routine read a charcter from the SIO and put it into a circular memory buffer from were it could be accessed by the application software. But I had obviously reenabled interrupts too early, just before the characters were inserted into the memory buffer. The SIO issued the next interrupt, the interrupt routine picked the character, enabled interrupts again, ... The last character in the hardware buffer thus made it first in the memory buffer, overtaking the other characters waiting to be inserted.
This was a really hard one to debug (no debugger, no incircuit emulator, just looking at my Z80 assembly listing and a lot of thinking...)
I rarely use debuggers even on my more sophisticated projects (C and Java). I still prefer to look at my code and send out logging info to clarify what my program is doing.
|