Fri, 15 Apr 2005 17:05:31 +0200
This may not have the merit of anything new, but I
do not want to resist showing you the following from
It took me a long time to track down, and I found the error. I was hoping to be able to report a snazzy bug, but it is because I wrote to an array out of bounds, and I must have corrupted another variable intermittently (for the last several years). I guess changing the name of the variable may have moved it in memory! The code is in the ADC interrupt.
if (nNextAdc==8) nNextAdc=0;
I try to store the 8 channels into an array but all 8 channels are shifted one index in the array when I print them out.
printf("x: %i\r\n", (int)(ADChannels);
this prints out ADC channel 1 unless I subtract 1 from nNextAdc like above.
so the index 0 is ADC channel 1 instead of ADC channel 0. So the "solution" I used was to write to index -1 to 7, and somehow this corrected the problem, but then I was also corrupting other memory I guess! :) Any sample code that continously logs all 8 ADC channels to an array? (without corrupting memory!)
I have a 1 bit offset somewhere I know, but I am not sure where..