Everything

Usage example

Get the A/D conversion result of 2 pins alternately.

 

[GUI setting example]

A/D convertor

Used

ADC

Used

A/D convertor operation setting

Used

Comparator operation setting

Operation

Resolution

8 bits

VREF(+) setting

VDD

VREF(-) setting

VSS

Trigger setting mode

Software trigger mode

Operation mode setting

One-shot select mode

ANI0 - ANI23 analog input selection

ANI0 - ANI1

A/D channel selection

ANI0

Conversion time mode

Normal 1

Conversion time

34 (1088/fCLK)(μs)

Conversion result upper/lower bound value setting

Generates an interrupt request (INTAD) when ADLLADCRHADUL

Upper bound (ADUL) value

255

Lower bound (ADLL) value

0

Use A/D interrupt (INTAD)

Used

Priority

Low

 

 

[API setting example]

r_main.c

void main(void)

{

       R_MAIN_UserInit();

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

       /* Start the AD converter */

       R_ADC_Start();

 

       while (1U)

       {

              ;

       }

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

}

 

r_cg_adc_user.c

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

volatile uint8_t g_adc_ch000_value;

volatile uint8_t g_adc_ch001_value;

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

 

static void __near r_adc_interrupt(void)

{

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

       /* Stop the AD converter */

       R_ADC_Stop();

 

       if(ADS == (uint8_t)ADCHANNEL0)

       {

              /* Return the higher 8 bits conversion result */

              R_ADC_Get_Result_8bit((uint8_t *)&g_adc_ch000_value);

 

              /* Start the AD converter */

              R_ADC_Set_ADChannel(ADCHANNEL1);

              R_ADC_Start();

       }

       else

       {

              /* Return the higher 8 bits conversion result */

              R_ADC_Get_Result_8bit((uint8_t *)&g_adc_ch001_value);

       }

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

}