Skip to main content
aeolia_amha
Associate III
June 20, 2010
Question

while loop forever ADC problem

  • June 20, 2010
  • 5 replies
  • 1101 views
Posted on June 20, 2010 at 08:41

while loop forever ADC problem

    This topic has been closed for replies.

    5 replies

    raptorhal2
    Lead
    May 17, 2011
    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

    aeolia_amha
    Associate III
    May 17, 2011
    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?

    trevor23
    Associate III
    May 17, 2011
    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.

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

    Is your ADCvalue volatile? It should be.

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

    You're right, it should be volatile.

    while(1)

    {

    put ADC here

    executable code

    }