cancel
Showing results for 
Search instead for 
Did you mean: 

ADC activation with STR750 - I need some help

dany
Associate II
Posted on January 14, 2008 at 14:30

ADC activation with STR750 - I need some help

2 REPLIES 2
dany
Associate II
Posted on December 23, 2007 at 12:10

I'm trying to activate the ADC in STR750 without success.

I'm running in a loop waiting for a FLAG to be set for ever

Attach below my code

Can any one help?

ADC setup code:

void ADC_setCFG(USHORT ConversionMode, LONG FirstChannel, LONG ChannelNumber)

{ /* 1: ADC_setCFG() */

ADC_InitTypeDef ADC_InitStructure;

ADC_StructInit(&ADC_InitStructure);

/* ADC configuration */

ADC_InitStructure.ADC_ConversionMode = ConversionMode;

ADC_InitStructure.ADC_ExtTrigger = ADC_ExtTrigger_Disable;

ADC_InitStructure.ADC_AutoClockOff = ADC_AutoClockOff_Disable;

ADC_InitStructure.ADC_SamplingPrescaler = 32;

ADC_InitStructure.ADC_ConversionPrescaler = 32;

ADC_InitStructure.ADC_FirstChannel = FirstChannel;

ADC_InitStructure.ADC_ChannelNumber = ChannelNumber;

ADC_Init(&ADC_InitStructure);

} /* 1: ADC_setCFG() */

void ADC_InitHW(void)

{ /* 1: ADC_InitHW(void) */

EIC_IRQInitTypeDef EIC_IRQInitStructure;

FlagStatus CalibrationDone;

ADC_DeInit();

MRCC_PeripheralSWResetConfig(MRCC_Peripheral_ADC,ENABLE);

ADC_InitInputs();

/* by default set ADC configuration for SCAN mode, starting with inputs 0, and scan all 16

inputs (15 = 16 - 1 , see manual)

*/

ADC_setCFG(ADC_ConversionMode_Scan, ADC_CHANNEL0, 15);

/* Configure the IEC for the ADC interrupts. */

EIC_IRQInitStructure.EIC_IRQChannelCmd = ENABLE;

EIC_IRQInitStructure.EIC_IRQChannel = ADC_IRQChannel;

EIC_IRQInitStructure.EIC_IRQChannelPriority = 1;

EIC_IRQInit(&EIC_IRQInitStructure);

ADC_ITConfig(ADC_IT_ALL, ENABLE);

/* Enable ADC */

ADC_Cmd(ENABLE);

/* Start calibration */

ADC_StartCalibration(ADC_CalibAverage_Enable);

CalibrationDone = SET;

while (CalibrationDone != RESET)

{

CalibrationDone = ADC_GetCalibrationStatus();

}

} /* 1: ADC_InitHW(void) */

void ADC_Start(void)

{

ADC_ConversionCmd (ADC_Conversion_Start);

}

This is the activation code:

ADC_Start();

while (1)

{

adc_flag = ADC_GetFlagStatus(ADC_FLAG_EOC);

if (adc_flag == SET)

{

ADC_ClearFlag(ADC_FLAG_EOC);

for (i = 0; i < 16 ; i++)

{

adc_value = ADC_GetConversionValue(i);

}

}

}

christophe239955_st
Associate II
Posted on January 14, 2008 at 14:30

Are the ADC Channel pin configured? and the GPIO clock enabled?