Reply
Posts: 68
Registered: ‎07-03-2017

ADC single scan EFM32LG330

Hello

i try to scan 3 channels with ADC single scan with the following code: 

    ADC_InitSingle_TypeDef singleInit = ADC_INITSINGLE_DEFAULT;

    //PD0= Init for single conversion sensor3
    singleInit.reference = adcRefVDD;
    singleInit.input      = adcSingleInpCh0;
    /* The datasheet specifies a minimum aquisition time when sampling VDD/3 */
    /* 32 cycles should be safe for all ADC clock frequencies */
    singleInit.acqTime = adcAcqTime32;
    ADC_InitSingle(ADC0, &singleInit);
    ADC_Start(ADC0, adcStartSingle);
    /* Wait while conversion is active */
    while (ADC0->STATUS & ADC_STATUS_SINGLEACT)
    ;
    /* Get ADC result */
    sensor_sampleFIFO[SENSOR3][sensor_sampleFIFO_index] = ADC_DataSingleGet(ADC0);
    ADC_Reset(ADC0);



    //PD1= Init for single conversion sensor2
    singleInit.input      = adcSingleInpCh1;
    /* The datasheet specifies a minimum aquisition time when sampling VDD/3 */
    /* 32 cycles should be safe for all ADC clock frequencies */
    singleInit.acqTime = adcAcqTime32;
    ADC_InitSingle(ADC0, &singleInit);
    ADC_Start(ADC0, adcStartSingle);
    /* Wait while conversion is active */
    while (ADC0->STATUS & ADC_STATUS_SINGLEACT)
    ;
    /* Get ADC result */
    sensor_sampleFIFO[SENSOR2][sensor_sampleFIFO_index] = ADC_DataSingleGet(ADC0);
    ADC_Reset(ADC0);


    //PD2= Init for single conversion sensor1
    singleInit.input      = adcSingleInpCh2;
    /* The datasheet specifies a minimum aquisition time when sampling VDD/3 */
    /* 32 cycles should be safe for all ADC clock frequencies */
    singleInit.acqTime = adcAcqTime32;
    ADC_InitSingle(ADC0, &singleInit);
    ADC_Start(ADC0, adcStartSingle);
    /* Wait while conversion is active */
    while (ADC0->STATUS & ADC_STATUS_SINGLEACT)
    ;
    /* Get ADC result */
    sensor_sampleFIFO[SENSOR1][sensor_sampleFIFO_index] = ADC_DataSingleGet(ADC0);
    ADC_Reset(ADC0);

    sensor_sampleFIFO_index++;
    if (sensor_sampleFIFO_index>SENSOR_NUMBER_SAMPLES)
    {
        sensor_sampleFIFO_index=0;
        sensor_minimun_sample_done=true;
    }
But this seems not to work

Can we scan several channels one after the other in single scan like this ?

thanks

Posts: 2,375
Registered: ‎10-14-2014

Re: ADC single scan EFM32LG330

I suggest you take a look at the AN0021SW (main_adc_example_gecko_s0.c) and try the scan mode. The section 28.3.7.3 of the reference manual cover the scan mode description.

 

 

WeiguoLu
Posts: 68
Registered: ‎07-03-2017

Re: ADC single scan EFM32LG330

Hello

thanks for the reply, but i i'm wondering if performing 3 single scans on 3 differents channels can be done with ADC_Reset(ADC0) function call between each scan...

regards

Posts: 2,375
Registered: ‎10-14-2014

Re: ADC single scan EFM32LG330

I think there is no problem. But you uploaded code don't use the scan mode. I suggest you try to read the AN0021 and the reference manual to check how to implement the scan mode.

 

WeiguoLu
Highlighted
Posts: 68
Registered: ‎07-03-2017

Re: ADC single scan EFM32LG330

Hello

thanks for the reply

Yes, I use 3  single conversions (no scan) with reset between each conversion.

The scan example uses DMA and i can't make it work properly...

regards