2023-03-14 10:50 PM
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 .
2023-03-17 02:02 AM
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.