I took a look at the AD configuration of C809 last night. It is also relatively simple. The main functions are: Peripheral enable register 0 (PER0) A/D converter mode register 0 (ADM0) A/D converter mode register 2 (ADM2) A/D conversion result high-order storage register (ADCRH) A/D conversion result low-order storage register (ADCRL) Analog input channel specification register (ADS) Then there are 2 registers for port mode: Port mode registers 0, 1 (PM0, PM1) Port mode control registers 0, 1 (PMC0, PMC1) After configuration, AD values can be collected. Regarding the reference voltage of AD, the data sheet
The manual recommends that after starting the AD channel, the MCU should enter halt mode to obtain more accurate AD values. The acquisition buffers of all channels share the conversion result registers (ADCRH, ADCRL). It is worth noting that AIN0 and serial port TX pins are multiplexed.
R_ADC0_Start(); /* Start AD converter */ HALT(); ADIF = 0U; /* Clear INTAD request */ R_ADC_Get_Result( &result_buffer0 ); /* Get AIN0 result */ R_ADC1_Start(); /* Start AD converter */ HALT(); /* wait for UART Rx interrupt */ ADIF = 0U; /* Clear INTAD request */ R_ADC_Get_Result( &result_buffer1 ); /* Get AIN1 result */