[Kinetis KEAZN64] ADC conversion does not start

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

[Kinetis KEAZN64] ADC conversion does not start

628 Views
mohammedaboelna
Contributor III

Hello,

When I try to convert ADC channel once, it is working good.

However; when i do this conversion many consecutive times by for loop for example, sometimes conversion does not start. Note that I read 4 channels 10 consecutive times.

here is my code,

Regarding initialization function:

/* Select ADCACLK, no divide, 12 bit conversion,
* ADLPC = 0 (default) => hi speed config,
* ADIV = 0 (default) => clock rate = input clock/1,
* ADLSMP = 0 (default) => short sample time,
* MODE = 2 => 12 bit conversion,
* ADICLK= 0 => Bus clock source */
ADC_SC3 = 0x00000008;

/* ADTRG = 0 (default) => SW Trigger,
* ACFE = 0 (default) => compare function disabled,
* REFSEL = 0 (default)=> default ref volt pin pair */
ADC_SC2 = 0x00000000;

/* Disable module (default state),
* AIEN = 0 => Interrupts disabled,
* ADCO = 0 => Continuous conversions disabled,
* ADCH = 1F => Module disabled */
ADC_SC1 = 0x0000001F;

 

Regarding conversion function with the for loop:

 

channelsResults[0] = 0;
channelsResults[1] = 0;
channelsResults[2] = 0;
channelsResults[3] = 0;

for (iteration = 0; iteration < 10; iteration++)

{
/* Specify next channel for conversion */
ADC_SC1 = ADC_SC1_ADCH(12);
/* Test conversion complete flag */
while (ConversionCompleted () == 0){}
/* Read converted value */
channelsResults[0] = channelsResults[0] + ADC_R;


/* Specify next channel for conversion */
ADC_SC1 = ADC_SC1_ADCH(13);
/* Test conversion complete flag */
while (ConversionCompleted () == 0){}
/* Read converted value */
channelsResults[1] = channelsResults[1] + ADC_R;


/* Specify next channel for conversion */
ADC_SC1 = ADC_SC1_ADCH(14);
/* Test conversion complete flag */
while (ConversionCompleted () == 0){}
/* Read converted value */
channelsResults[2] = channelsResults[2] + ADC_R;


/* Specify next channel for conversion */
ADC_SC1 = ADC_SC1_ADCH(15);
/* Test conversion complete flag */
while (ConversionCompleted () == 0){}
/* Read converted value */
channelsResults[3] = channelsResults[3] + ADC_R;


}

channelsResults[0] = channelsResults[0] / 10;
channelsResults[1] = channelsResults[1] / 10;
channelsResults[2] = channelsResults[2] / 10;
channelsResults[3] = channelsResults[3] / 10;

Tags (2)
0 Kudos
2 Replies

401 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

I would recommend customer to refer the [SDK Software Drivers for KEAZ128_KEAZ64 using S32DS] software package, which provides ADC module driver and related demo.

Wish it helps.

best regards,

Mike

0 Kudos

401 Views
IlConte
Contributor IV

I have a similar problem and I ask you if you have, and how, solved the problem.

Thanks

0 Kudos