ADC problems with STR7
Company  
ST Home | Microcontrollers

Index  »  ARM7 STR7  »  ADC problems with STR7
     
   ADC problems with STR7
 Moderated by :   »  AnisAS  -  coucou

Author
beginning argument    ( Replies received: 3 )
zaz426   Posted 30-01-2007 at 17:15   



Registered on :
01-30-2007

From USA

Messages : 1

 OFF-Line

I copied the program from the ST application note and I cannot get the ADC to give me a good reading. I basically have a DC voltage between 0.6 and 0.75 volts that I need to measure. I dont even need the 12 bit resolution, however when I run the ADC_12 I get a return value of either 0x95E or 0x6A1. Neither of which I believe since I change the input voltage and the results are the same. Additionally, the CSR reguister is always set as an overrun condition?
My code is below I am using the IAR workbench.
void ADC_init (void)
{


/* Configure the ADC analog input pin to High Impedance Analog Input */
GPIO_Config (GPIO1, AIN0, GPIO_HI_AIN_TRI);


/* Initialise the TIM0 registers */
// TIM_Init ( TIM0 );

/* Set TIM0 prescalar division factor to 0x0F */
// TIM_PrescalerConfig (TIM0, 0x0F);

/* Set the TIM0 counter to 0XFFFC */
// TIM_CounterConfig (TIM0, TIM_CLEAR);

/* Initialize the ADC Registers */
ADC12_Init();

/* Configure the ADC Prescaler */
ADC12_PrescalerConfig(1000);

}

int ADC_Convert()
{
#ifdef ADC_SINGLE



TIM_CounterConfig (TIM0, TIM_CLEAR);
/* Select the Single mode of conversion */
ADC12_ModeConfig (ADC12_SINGLE);


/* Select the channel to be converted */
ADC12_ChannelSelect(ADC12_CHANNEL0);


/* Enable the converter */
ADC12_ConversionStart();


/* Repeat until end of conversion */

ADC12_Clear();
ADC12_ConversionStart();
while (ADC12_FlagStatus (ADC12_DA0)==RESET);

ADC12_ConversionStop();

if( ADC12_FlagStatus (ADC12_OR) == RESET)
{
/* Get the Counter value */
Counter = TIM0->CNTR;

/* Read the conversion result*/
Conv_Res = ADC12_ConversionValue(ADC12_CHANNEL0);
}
#endif


/* Disable the Converter */
ADC12_ConversionStop();
return Conv_Res ;

you can e-mail any suggestions to zaz426@yahoo.com
thank you



 Profile   Quote  
Rave   Posted 31-01-2007 at 21:05   



Registered on :
04-13-2004

Messages : 55

 OFF-Line

Hello zaz426,

Could you please inform me about your hardware environement ?
Name of the board and its revision and if you have shematics of the ADC
part.

Before using the STR71x ADC you have to perform a calibration ( Hardware
& Software ) providing a stable 2.5 volts and 0 level and use the Software calibration formula in ST Software library in order to linearise your converted data.

I hope that this may help you

Regards,

rave




 Profile   Quote  
mail1   Posted 12-06-2008 at 16:48   



Registered on :
01-25-2008

Messages : 2

 OFF-Line

Hi,

I am using the ST - C-library and would like to know how to calibrate the ADC - there is no command described!



 Profile   Quote  
avelez   Posted 24-07-2008 at 13:18   



Registered on :
01-07-2008

Messages : 12

 OFF-Line

Did you try to set the ports as analog input?

BTW, the method for calibrating the adc is in the ADC section of the reference manual. However, there is no library or routine that makes the work for you. You'll have to do it yourself



 Profile   Quote  
On Top

Search in the forums
 
Jump To