cancel
Showing results for 
Search instead for 
Did you mean: 

Starting with ADC

bea
Associate II
Posted on April 10, 2007 at 04:49

Starting with ADC

4 REPLIES 4
bea
Associate II
Posted on April 02, 2007 at 05:24

Hi!

I am new with the STR71 and I am trying to use the ADC to sample four different analog inputs, so, I think I can use Round Robin mode.

This is my code for init the ADC using the ST libraries:

// Configure the 4 ADC analog input pin to High Impedance Analog Input

GPIO_Config (GPIO1, ADC12_DA0, GPIO_HI_AIN_TRI);

GPIO_Config (GPIO1, ADC12_DA1, GPIO_HI_AIN_TRI);

GPIO_Config (GPIO1, ADC12_DA2, GPIO_HI_AIN_TRI);

GPIO_Config (GPIO1, ADC12_DA3, GPIO_HI_AIN_TRI);

// Initialize the ADC Registers

ADC12_Init();

// Configure the ADC Prescaler

ADC12_PrescalerConfig(500);

// Select the round robin mode of conversion

ADC12_ModeConfig (ADC12_ROUND);

//Enable the converter

ADC12_ConversionStart();

And in my program:

if((ADC12_FlagStatus(ADC12_DA0)==SET)||(ADC12_FlagStatus(ADC12_DA1)==SET)||(ADC12_FlagStatus(ADC12_DA0)==SET)||(ADC12_FlagStatus(ADC12_DA0)==SET))

{

//Disable the converter

ADC12_ConversionStop();

if(ADC12_FlagStatus(ADC12_DA0)==SET) Line1=ADC12_ConversionValue(ADC12_CHANNEL0);

if(ADC12_FlagStatus(ADC12_DA1)==SET) Line2=ADC12_ConversionValue(ADC12_CHANNEL1);

if(ADC12_FlagStatus(ADC12_DA2)==SET) Line3=ADC12_ConversionValue(ADC12_CHANNEL2);

if(ADC12_FlagStatus(ADC12_DA3)==SET) Line4=ADC12_ConversionValue(ADC12_CHANNEL3);

//Clear all flags writing low

ADC12->CSR &= (~(ADC12_DA0| ADC12_DA1| ADC12_DA2| ADC12_DA3));

//Enable the converter again

ADC12_ConversionStart();

}

I can emulate the program step by step (with the RLink from Raisonance in Flash memory) and everything is o.k. but when I use the run option, the ADC doesn’t work. I think that it’s not due to the ADC calibration and in my application it is not necessary.

Can anybody help me?

kaouther
Associate II
Posted on April 05, 2007 at 06:12

Hi,

Yes this behavior could not be due to the calibration.Are you using the STR711 Reva board from Raisonance? Could you send us the hole software project to reproduce the behavior and verify all the settings?

Regards.

kaouther
Associate II
Posted on April 05, 2007 at 07:15

Hi,

Yes this behavior could not be due to the calibration.Are you using the STR711 Reva board from Raisonance? Could you send us the hole software project to reproduce the behavior and verify all the settings?

Regards.

bea
Associate II
Posted on April 10, 2007 at 04:49

Thanks, it is working o.k.

I read in a application note that you have to wait, at least, 100ms between the instruction

// Initialize the ADC Registers

ADC12_Init();

and the instruction

// Configure the ADC Prescaler

ADC12_PrescalerConfig(500);

Now, I’m waiting this time and everything is o.k.

Regards