Skip to main content
Visitor II
April 24, 2007
Question

ADC problems with STR5

  • April 24, 2007
  • 2 replies
  • 724 views
Posted on April 24, 2007 at 13:02

ADC problems with STR5

    This topic has been closed for replies.

    2 replies

    Visitor II
    April 24, 2007
    Posted on April 24, 2007 at 09:32

    I am using the ST sw library to calculate A/D value (for a touch screen). I can read correctly the AD_CHANNEL1 but not the AD_CHANNELL0. The voltage at the A/D micro is correct. I am using the OneShot method but I tried also the Scan. What's wrong in my sw (I attached the main A/D part)?

    GPIO_Init(GPIO1, &GPIO_InitStructure);

    /* ADC Channel pin configuration */

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3 ;

    GPIO_Init(GPIO0, &GPIO_InitStructure);

    Delay(10000);

    ADC_InitStructure.ADC_ConversionMode = ADC_ConversionMode_OneShot;

    ADC_InitStructure.ADC_ExtTrigger = ADC_ExtTrigger_Disable;

    ADC_InitStructure.ADC_AutoClockOff = ADC_AutoClockOff_Disable;

    ADC_InitStructure.ADC_SamplingPrescaler = 0;

    ADC_InitStructure.ADC_ConversionPrescaler = 0;

    ADC_InitStructure.ADC_FirstChannel = ADC_CHANNEL0;

    ADC_InitStructure.ADC_ChannelNumber = 2;

    ADC_Init(&ADC_InitStructure);

    Delay(10000);

    /* Enable ADC */

    ADC_Cmd(ENABLE);

    Delay(10000);

    /* Start conversion */

    ADC_ConversionCmd(ADC_Conversion_Start);

    .........................................

    while(1) // Main loop

    {

    ....................................

    Delay(10000);

    y_Touch=ADC_GetConversionValue(ADC_CHANNEL1);

    x_Touch=ADC_GetConversionValue(ADC_CHANNEL0);

    ADC_ConversionCmd(ADC_Conversion_Start); }

    ....................................

    }

    Visitor II
    April 24, 2007
    Posted on April 24, 2007 at 13:02

    Sorry! There was a stupid sw bug in another part of the program.