2010-06-19 11:41 PM
while loop forever ADC problem
2011-05-17 04:55 AM
I also tried using for loops with different counters and using the actual ADCs like for(ctr=0;vtrial<threshold;ctr++), it still loops forever. I also tried using the ADC value and not converting it to double also didn't work. while(Vtry<1000), 0=0v, 3.3=4095. It still looped forever. Any suggestions?
2011-05-17 04:55 AM
Using your debugger, step through the program to make sure it is converting the values that you think it should be. Make sure that it is cycling so that the ADC is converting more than once. If you are using a library examples in your code, they only convert once per program load or reset.
Cheers, Hal2011-05-17 04:55 AM
Is your ADCvalue volatile? It should be.
And why are you using floating point?2011-05-17 04:55 AM
Can you show where ADCvalue is changed (e.g. in another task or by interrupt or by DMA etc.). In all theses cases it needs to be volatile as previously stated.
2011-05-17 04:55 AM
You're right, it should be volatile.
while(1)
{
put ADC here
executable code
}