cancel
Showing results for 
Search instead for 
Did you mean: 

How to select the ADC mode from scan (default ) to one shot mode? Should I want to edit the Low Level Driver to change the mode which is in MCR register?

Sivashankar
Associate II

I am usingSPC56Ecxx. I need to change the ADC mode from scan (default) to one shot mode. There is no options provided in SPC5 studio. ADC MCR register has the option for mode selection.Should I want to change in LLD or any other option to change the mode? Thanks in advance @Erwan YVIN​ .

1 REPLY 1
ODOUV.1
ST Employee

Hello,

current driver do not supports this option.

you will need to modify the driver in adc_lld.h:

#define ADC_ONE_SHOT_MODE (0 << 0)

#define ADC_SCAN_MODE (1 << 0)

typedef struct {

 uint32_t         options;

} ADCConfig;

you will need to modify the driver in function adc_lld_start of adc_lld.c:

 /* Sets MCR Register.*/

 if (config == NULL) {

 adcp->adc_tagp->MCR.R = ADC_MCR_OWREN | ADC_MCR_MODE;

 } else {

 if (config->options & ADC_SCAN_MODE) {

 adcp->adc_tagp->MCR.R = ADC_MCR_OWREN | ADC_MCR_MODE;

 } else {

 adcp->adc_tagp->MCR.R = ADC_MCR_OWREN;

 }

 }

and modify your application:

 ADCConfig config;

 config.options = ADC_ONE_SHOT_MODE;

 adc_lld_start(&ADCD2, &config);

Best regards.