[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avr-gcc-list] buggy variable naming with underscores

From: Ben Mann
Subject: RE: [avr-gcc-list] buggy variable naming with underscores
Date: Tue, 15 Mar 2005 08:34:08 +0800

Hi Jamie,

Um, the code below would indeed cause the problem you mention.  Instead try


And it should work properly, requiring 

printf("x: %i\r\n", (int)(ADChannels[0]);

to print out channel 0.

If you work through your code you will see that on the next call to the
signal after setting nNextAdc=0, you will be writing
which is going to scribble memory somewhere; it also explains why you are
then reading index -1 to get the byte.

Ben Mann


u08 lt; 
u08 ht; 
ht=inp(ADCH)& 0x03; 
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. ie.
printf("x: %i\r\n", (int)(ADChannels[0]);

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!)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]