AnsweredAssumed Answered

ADC3_IN2 on STM32F427

Question asked by JeepersCreepers on Jul 1, 2015
Latest reply on Jul 7, 2015 by JeepersCreepers
 Existing code, ADC2_IN1 on PA1 works polled 100 numbers vary from 150 to 3050 sinusoid.  HW guy added ADC3_IN2 on PA2.
Changed the code as below, but 100 numbers are all between 3013 and 3015, although can see a clipped sinusoid on Bitscope.  Any ideas what to check?
void ecg_init (void)
{
    static GPIO_InitTypeDef         GPIO_InitStructure;
    static ADC_InitTypeDef          ADC_InitStructure;
    
    // [dy] ECG_OUT2 is on PA2 ADC3_IN2
    RCC_AHB1PeriphClockCmd(BSP_ECG_ANALOG_INPUT_GPIO_RCC_AHB1_PERIPH, ENABLE);
    
    // [dy-ECG1] RCC_APB2PeriphClockCmd(BSP_ECG_ANALOG_INPUT_ADC_RCC_APB2_PERIPH, ENABLE);
    //[dy] RCC Enable for ECG2
    RCC_APB2PeriphClockCmd(BSP_ECG2_ANALOG_INPUT_ADC_RCC_APB2_PERIPH, ENABLE);
    /* Configure GPIO (ECG) as analog input ******************************/
    //[dy] GPIO_Pin_2 for ECG2
    GPIO_InitStructure.GPIO_Pin  = /* [dy-ECG1] BSP_ECG_ANALOG_INPUT_GPIO_PIN |*/ BSP_ECG2_ANALOG_INPUT_GPIO_PIN;  
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
    GPIO_Init(BSP_ECG_ANALOG_INPUT_GPIO_PORT, &GPIO_InitStructure);

    ssm_adc_common_init ();

    /* ADC ECG Init ****************************************************************/
    ADC_InitStructure.ADC_Resolution           = ADC_Resolution_12b;
    ADC_InitStructure.ADC_ScanConvMode         = DISABLE;
    ADC_InitStructure.ADC_ContinuousConvMode   = ENABLE;  // THIS WAS Different
    ADC_InitStructure.ADC_ContinuousConvMode   = DISABLE;
    ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
    ADC_InitStructure.ADC_DataAlign            = ADC_DataAlign_Right;
    ADC_InitStructure.ADC_NbrOfConversion      = 1;
    // [dy-ECG1] ADC_Init(BSP_ECG_ANALOG_INPUT_ADC_NUM, &ADC_InitStructure);
    // [dy] ADC_Init for ECG2
    ADC_Init(BSP_ECG2_ANALOG_INPUT_ADC_NUM, &ADC_InitStructure);    
    // [dy] BSP_ECG2_ANALOG_INPUT_ADC_NUM  ADC3   

    // NV 20130926 KEY Do this only once...
#ifdef ECG1    
    ADC_RegularChannelConfig(BSP_ECG_ANALOG_INPUT_ADC_NUM,
                             BSP_ECG_ANALOG_INPUT_ADC_CHANNEL, 1, ADC_SampleTime_3Cycles);
    ADC_Cmd(BSP_ECG_ANALOG_INPUT_ADC_NUM, ENABLE);
#endif
    // [dy] BSP_ECG2_ANALOG_INPUT_ADC_CHANNEL ADC_Channel_2 ...
    ADC_RegularChannelConfig(BSP_ECG2_ANALOG_INPUT_ADC_NUM,
                             BSP_ECG2_ANALOG_INPUT_ADC_CHANNEL, 1, ADC_SampleTime_3Cycles);    
    ADC_Cmd(BSP_ECG2_ANALOG_INPUT_ADC_NUM, ENABLE);
    
}

Outcomes