Everything

Usage example

Supply the generated reference voltage to A/D convertor.

 

[GUI setting example]

Voltage reference

VR

Used

Voltage reference operation setting

Used

1/2 AVDD voltage output operation setting

Enable

VREFOUT pin output level setting

1.8V

 

12-Bit A/Dconvertor

ADC

Used

A/D convertor operation setting

Used

A/D conversion clock setting

PCLK

A/D conversion mode setting

High-speed conversion

VREF+setting

AVREFP/VREFOUT

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

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 value3.667)

A/D converted value count setting

Addition mode

Interrupt setting

Enable AD conversion end interruptINTAD

Priority

Level 3 (Low Priority)

Data registers setting

 

 

 

[API setting example]

r_cg_main.c

void main(void)

{

       R_MAIN_UserInit();

       /* Start user code. Do not edit comment generated here */

       /* Start VR module operation */

       R_VR_Start();

 

       /* 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 include. Do not edit comment generated here */

#include "r_cg_vr.h"

/* End user code. Do not edit comment generated here */

 

/* Start user code for global. Do not edit comment generated here */

volatile uint16_t g_12adc_ch000_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 VR module operation */

       R_VR_Stop();

 

       /* Stop AD converter */

       R_12ADC_Stop();

 

       /* Get AD converter result */

       R_12ADC_Get_ValueResult(ADCHANNEL0, (uint16_t *)&g_12adc_ch000_value);

       /* End user code. Do not edit comment generated here */

}