Skip to main content
Visitor II
January 14, 2008
Question

ADC activation with STR750 - I need some help

  • January 14, 2008
  • 2 replies
  • 745 views
Posted on January 14, 2008 at 14:30

ADC activation with STR750 - I need some help

    This topic has been closed for replies.

    2 replies

    danyAuthor
    Visitor II
    December 23, 2007
    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);

    }

    }

    }

    Visitor II
    January 14, 2008
    Posted on January 14, 2008 at 14:30

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