AnsweredAssumed Answered

MKE02Z ADC ADC_SC1 & COCO issue

Question asked by Neil Porven on Dec 3, 2015
Latest reply on Dec 6, 2015 by Neil Porven

Hi everyone,

 

I am stuck with the following and I don't know if this is a C language issue, compiler, IDE, or something else?

By the way, I am using KDS 3.0 and I am not using PE.

 

After setting up the ADC, I start a conversion, then follow it with an if statement waiting for COCO to set.

 

if (ADC_SC1 & ADC_SC1_COCO_MASK)   //Wait until the conversion is complete

    Analog_This.ui24V = ADC->R;            //Retrieve the conversion

 

The issue is that after the if statement, if I step through the code, it never executes (Analog_This.ui24V = ADC->R;).

 

Registers.jpg

 

I also tried this:

 

if (ADC->SC1 & ADC_SC1_COCO_MASK)   //Wait until the conversion is complete

 

I also tried this:

 

if ((ADC->SC1 & ADC_SC1_COCO_MASK) == 1)   //Wait until the conversion is complete

 

I also tried this:

 

if ((ADC_SC1 & ADC_SC1_COCO_MASK) == 1)   //Wait until the conversion is complete

 

All these combinations didn't work!

 

Thank you,

Neil

Outcomes