AnsweredAssumed Answered

STM32F103RET6 ADC reads voltage with no voltage at pin

Question asked by charlie on Apr 6, 2014
Latest reply on Apr 6, 2014 by charlie
If i read any of the ADC's i see a voltage of about 1736mv it changes a little depending on the sampling speed, i've used non continuous reads, and continuous DMA , both mostly the same, reads  the same in circuit or out. if i put 2v6 on it, it'll read it exactly correct, same at 0v

i've used stm32lib, in different ways but always the same.

i have all the vss gnd, vdd 3v3, vdda via a ferrite to 3v3 with a 10uF and 100nF cap to vssa. 72mhz speed with external 8mhz xtal.

am i just completely misunderstanding something? 
input voltages are stable

schematic
http://i.imgur.com/AfaWw69.png

its a larger project, i cut out the adc part, i can make a simpler full example if nothing obvious or misunderstand on my part.

ADC_RegularChannelConfig ( ADC1, ADC_Channel_0, 1, ADC_SampleTime_55Cycles5 );
 
ADC_SoftwareStartConvCmd ( ADC1 ,ENABLE ); //Start the conversion
 
while ( ADC_GetFlagStatus ( ADC1, ADC_FLAG_EOC ) == RESET ); //Processing the conversion
 
return ADC_GetConversionValue ( ADC1 ) /4; //Return the converted data

adc setup
void ADC_Configuration ( void )
{
    ADC_InitTypeDef ADC_InitStructure;
 
#if DMA_ADC == 1
 
    DMA_InitTypeDef DMA_InitStructure;
 
    memset ( &DMA_InitStructure,0,sizeof ( DMA_InitStructure ) );
    memset ( &ADC_InitStructure,0,sizeof ( ADC_InitStructure ) );
 
    /* Enable DMA1 clock */
    RCC_AHBPeriphClockCmd ( RCC_AHBPeriph_DMA1, ENABLE );
 
    /* Enable ADC1 clock */
    RCC_APB2PeriphClockCmd ( RCC_APB2Periph_ADC1, ENABLE );
 
    /* DMA1 channel1 configuration ---------------------------------------------*/
    DMA_DeInit ( DMA1_Channel1 );
    DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address;
    DMA_InitStructure.DMA_MemoryBaseAddr = ( u32 ) &ADC_Ampl[0];
    DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
    DMA_InitStructure.DMA_BufferSize = 2;
    DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
    DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
    DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
    DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
    DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
    DMA_InitStructure.DMA_Priority = DMA_Priority_Low;
    DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
    DMA_Init ( DMA1_Channel1, &DMA_InitStructure );
 
    /* Enable DMA1 channel1 */
    DMA_Cmd ( DMA1_Channel1, ENABLE );
 
    /* Disable the DMA1 Channel1 Transfer complete interrupt */
    DMA_ITConfig ( DMA1_Channel1, DMA_IT_TC, DISABLE );
#else
     
    /* Enable ADC1 clock */
    RCC_APB2PeriphClockCmd ( RCC_APB2Periph_ADC1, ENABLE );
#endif
 
    /* ADC1 configuration ------------------------------------------------------*/
    ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
     
#if DMA_ADC == 1
    ADC_InitStructure.ADC_ScanConvMode = ENABLE;
    ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
#else
    ADC_InitStructure.ADC_ScanConvMode = DISABLE;
    ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
#endif
    ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
    ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
    ADC_InitStructure.ADC_NbrOfChannel = 2;
    ADC_Init ( ADC1, &ADC_InitStructure );
 
    /* ADC0 regular channel configuration */
    ADC_RegularChannelConfig ( ADC1, ADC_Channel_0, 1, ADC_SampleTime_239Cycles5 );
 
    /* ADC1 regular channel configuration */
    ADC_RegularChannelConfig ( ADC1, ADC_Channel_1, 2, ADC_SampleTime_239Cycles5 );
 
#if DMA_ADC == 1
 
    /* Enable ADC1 DMA */
    ADC_DMACmd ( ADC1, ENABLE );
 
#endif
 
    /* Enable ADC1 */
    ADC_Cmd ( ADC1, ENABLE );
 
    /* Enable ADC1 reset calibaration register */
    ADC_ResetCalibration ( ADC1 );
 
    /* Check the end of ADC1 reset calibration register */
    while ( ADC_GetResetCalibrationStatus ( ADC1 ) );
 
    /* Start ADC1 calibaration */
    ADC_StartCalibration ( ADC1 );
 
    /* Check the end of ADC1 calibration */
    while ( ADC_GetCalibrationStatus ( ADC1 ) );
}

memset ( &GPIO_InitStructure,0,sizeof ( GPIO_InitStructure ) );
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 ;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init ( GPIOA, &GPIO_InitStructure );

thanks,

Outcomes