AnsweredAssumed Answered

070RB hangs when reading a register

Question asked by mike louaillier on Mar 24, 2017
Latest reply on Jul 4, 2017 by Jaroslav Becka

Hello can someone help me with this? it's a simple ADC conversion that hangs on line 8. i don't see how this is possible.

 

1      ADC1->CR |= (uint32_t)ADC_CR_ADSTART;  // start first conversion
2      count = 0;
3      while(((ADC1->ISR & ADC_ISR_EOC) == (uint32_t)reset)  &&  (count < timeout))  // wait for end of conversion
4        { count++; }
5      capVL = (uint16_t)ADC1->DR;  // read value
6      ADC1->CR |= (uint32_t)ADC_CR_ADSTART;  // start second conversion
7      count = 0;
8      while(((ADC1->ISR & ADC_ISR_EOC) == (uint32_t)reset)  &&  (count < timeout))  // wait for end of conversion
9        { count++; }
10//     while(count < timeout) count++;
11     capVH = (uint16_t)ADC1->DR;  // read value

 

if i conceal lines 8 & 9 and expose line 10, like so:

 

8//      while((ADC1->ISR & ADC_ISR_EOC) == (uint32_t)reset  &&  (count < timeout))  // wait for end of conversion
9//        { count++; }
10     while(count < timeout) count++;

 

then it runs fine. dunno why the ADC operation on line 6 isn't working, but working or not, it should still timeout and keep going. it's not supposed to just hang. WTF? it's just reading a register.

Outcomes