My MCU is a RA2A1 and I configured the ADC16 in Single Scan Mode with no averaging and ADCLK = 12MHz. I expect a conversion time of about 2µs (raw estimation based on data sheet) for the conversion of channel 0. But after doing a measurement of the internal temperature sensor all following conversions of channel 0 take more than 30µs.
I tracked that down to the r_adc_scan_cfg function. When configuring the ADC scan for the internal temperature sensor or the internal reference voltage this function calls r_adc_sensor_cfg which sets bits in the ADEXICR register. Configuring the scan for other channels does not clear these bits again and the ADC continues to use the slower timing.
My workaround is to clear ADEXICR every time before calling R_ADC_ScanCfg:
g_adc_ctrl.p_reg->ADEXICR = 0; // bug in FSP: ADEXICR newer gets cleared after first temp/vref configuration
fsp_err = R_ADC_ScanCfg(&g_adc_ctrl, &v_adc_channel_cfg);
My MCU is a RA2A1 and I configured the ADC16 in Single Scan Mode with no averaging and ADCLK = 12MHz. I expect a conversion time of about 2µs (raw estimation based on data sheet) for the conversion of channel 0. But after doing a measurement of the internal temperature sensor all following conversions of channel 0 take more than 30µs.
I tracked that down to the
r_adc_scan_cfg
function. When configuring the ADC scan for the internal temperature sensor or the internal reference voltage this function callsr_adc_sensor_cfg
which sets bits in the ADEXICR register. Configuring the scan for other channels does not clear these bits again and the ADC continues to use the slower timing.My workaround is to clear ADEXICR every time before calling
R_ADC_ScanCfg
: