cancel
Showing results for 
Search instead for 
Did you mean: 

while loop forever ADC problem

aeolia_amha
Associate II
Posted on June 20, 2010 at 08:41

while loop forever ADC problem

5 REPLIES 5
aeolia_amha
Associate II
Posted on May 17, 2011 at 13:55

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?

raptorhal2
Lead
Posted on May 17, 2011 at 13:55

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, Hal

domen23
Associate II
Posted on May 17, 2011 at 13:55

Is your ADCvalue volatile? It should be.

And why are you using floating point?
trevor23
Associate III
Posted on May 17, 2011 at 13:55

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.

aeolia_amha
Associate II
Posted on May 17, 2011 at 13:55

You're right, it should be volatile.

while(1)

{

put ADC here

executable code

}