Usage example
Get the A/D conversion result of 2 pins.
[GUI setting example]
12-Bit A/D convertor |
||||
ADC |
Used | |||
A/D convertor operation setting |
Used | |||
A/D conversion clock setting |
PCLK | |||
A/D conversion mode setting |
High-speed conversion | |||
VREF(+)setting |
AVDD | |||
VREF(-)setting |
AVSS | |||
Operation mode setting |
Single scan mode | |||
|
|
|
Conversion start trigger setting |
Software trigger |
|
|
|
Analog input channel setting |
|
|
|
|
ANI00 |
Used |
|
|
|
ANI00 addition/Average function |
Unused |
|
|
|
ANI01 |
Used |
|
|
|
ANI01 addition/Average function |
Unused |
|
|
|
Data registers setting |
|
|
|
|
ADconversion value addition count |
1-time conversion |
|
|
|
Data placement |
Right-alignment |
|
|
|
Automatic clearing |
Disable automatic clearing |
|
|
|
ANI00 input sampling time |
3.667(μs) (Actual value:3.667) |
|
|
|
ANI01 input sampling time |
3.667(μs) (Actual value:3.667) |
|
|
|
A/D converted value count setting |
Addition mode |
|
|
|
Interrupt setting |
Enable AD conversion end interrupt(INTAD) |
|
|
|
Priority |
Level 3 (Low Priority) |
[API setting example]
r_cg_main.c
void main(void)
{
R_MAIN_UserInit();
/* Start user code. Do not edit comment generated here */
/* Start AD converter */
R_12ADC_Start();
while (1U)
{
;
}
/* End user code. Do not edit comment generated here */
}
r_cg_12adc_user.c
/* Start user code for global. Do not edit comment generated here */
volatile uint16_t g_12adc_ch000_value;
volatile uint16_t g_12adc_ch001_value;
/* End user code. Do not edit comment generated here */
static void __near r_12adc_interrupt(void)
{
/* Start user code. Do not edit comment generated here */
/* Stop AD converter */
R_12ADC_Stop();
/* Get AD converter result */
R_12ADC_Get_ValueResult(ADCHANNEL0, (uint16_t *)&g_12adc_ch000_value);
R_12ADC_Get_ValueResult(ADCHANNEL1, (uint16_t *)&g_12adc_ch001_value);
/* End user code. Do not edit comment generated here */
}