renesas / fsp

Flexible Software Package (FSP) for Renesas RA MCU Family
https://renesas.github.io/fsp/
Other
182 stars 82 forks source link

ADC16 conversions get slow after a temperature sensor or a reference voltage conversion #342

Closed scriptorron closed 3 months ago

scriptorron commented 5 months ago

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);
renesas-brandon-hussey commented 5 months ago

This is being internally tracked using FSPRA-2350.