Hi Mark,
I reviewed your code snippet, it looks similar to my setup. Here is the comparison:
POWER_UP(6, SIM_SCGC6_ADC0); // enable clocks to module (yours)
SIM_SCGC |= SIM_SCGC_ADC_MASK; // Enable the ADC module (mine)
ADC_SC3 = (ADC_CFG1_ADIV_8 | ADC_CFG1_ADLSMP_LONG | ADC_CFG1_MODE_10 | ADC_CFG1_ADICLK_BUS2); // (yours)
ADC_SC3 = ADC_SC3_ADLPC_MASK | ADC_SC3_ADLSMP_MASK | ADC_SC3_MODE1_MASK | ADC_SC3_ADIV(3); // (mine)
ADC_SC2 = 0; // software trigger (yours)
ADC_SC2 = 0x00; //Software trigger, Default voltage reference (mine)
ADC_APCTL1 |= (ADC_APCTL1_AD12); // enable the pin's ADC function (yours)
ADC_APCTL1 = ADC_APCTL1_ADPC5_MASK; (mine)
ADC_SC1 = ADC_SC1_ADCH_12; // start conversion on channel 12 (yours)
ADC_SC1 = ADC_12VSignal_MASK; (mine)
(yours)
while ((ADC_SC1 & ADC_SC1_COCO) == 0) {} // wait for conversion to complete
return (ADC_R); // return the value
(mine)
if (ADC_SC1 & ADC_SC1_COCO_MASK) //Is the conversion is complete
Analog_This.ui24V = ADC->R; //Read the conversion
I am following this example straight from the KE02 Sub-Family Reference Manual
Example: 24.5.1.2.1 General ADC initialization routine
void ADC_init(void)
{
/* The following code segment demonstrates how to initialize ADC by low-power mode,
long
sample time, bus frequency, software triggered from AD1 external pin without FIFO
enabled
*/
ADC_APCTL1 = ADC_APCTL1_ADPC1_MASK;
ADC_SC3 = ADC_SC3_ADLPC_MASK | ADC_SC3_ADLSMP_MASK | ADC_SC3_MODE0_MASK;
ADC_SC2 = 0x00;
ADC_SC1 = ADC_SC1_AIEN_MASK | ADC_SC1_ADCH0_MASK;
}
My research regarding an existing ERRATA for the MKE02Z32VQH4 came back empty!
Freescale is not reporting an issue with what I am seeing????
Just as a test, I did the following line after my code to see what would happen:
ADC_APCTL1 = ADC_APCTL1_ADPC5_MASK; //APCTL1 is used to control the pins associated with channels 0-31
ADC_SC3 = ADC_SC3_ADLPC_MASK | ADC_SC3_ADLSMP_MASK | ADC_SC3_MODE1_MASK | ADC_SC3_ADIV(3); //Low power configuration,Long
ADC_SC2 = 0x00; //Software trigger, Default voltage reference
ADC_SC1 = ADC_12VSignal_MASK; //One Conversion Enable ;Input Channel AD4; Input Channel AD5
if (10 & 12) <--------- useless line just to see what happens......
bla bla bla......
just right before execution:
---> if (10 & 12) ******** COCO = 0x01
after stepping ******** COCO = 0x00
Very frustrating and by the way, it doesn't matter if I have the register open (where I am looking at it or not).
Anyway, why hasn't someone from Freescale jumped in to this post/issue/conversation (either confirming it or commenting about it)????
Thank you Mark for keeping up with me on this. Your probably scratching your head as I am.....
Regards,
Neil