AnsweredAssumed Answered

ADC stuck waiting for COCO (KL02Z)

Question asked by Simone Agha on Jul 22, 2014
Latest reply on Jul 24, 2014 by Simone Agha

I'm using the FRDM-KL02Z and reading from the ADC on an interrupt (OnEnd of a PWM signal). After running for a few minutes, the ADC will get stuck in the while loop of my getADC function:

 

int getADC(int adch) /* adch is the ADC channel (e.g. ADC_PDD_SINGLE_ENDED_AD10) */
{
  ADC_PDD_SetChannel(ADC0_BASE_PTR, ADC_SC1_ADCH_SHIFT, adch);
  while ((ADC0_SC1A & ADC_SC1_COCO_MASK) != ADC_SC1_COCO_MASK)
  { 
  /* Wait for measurement to complete */
 }
  return ADC0_RA; /* Return ADC value */
}


 

This happens even with no hardware averaging and the ADC resolution set to 8 bits. I calibrate the ADC at the program startup and set the ADC clock divisor to 1 and enable high speed mode. Why is the program hanging?

 

Thanks.

Outcomes