Everything

Usage example

Measure temperature by measuring the output voltage from the temperature sensor using the A/D converter.

 

[GUI setting example]

Temparature sensor

Used

TS

Used

Temparature sensor operation setting

Used

Operation mode setting

Normal-temparature range (mode 2)

 

A/Dconvertor

Used

ADC

Used

A/D convertor operation setting

Used

Comparator operation setting

Stop

Resolution setting

8 bits

VREF(+) setting

Internal reference voltage

VREF(-) setting

VSS

Trigger mode setting

Software trigger mode

Operation mode setting

On-shot select mode

ANI0 - ANI5Analog input selection

All digital

A/D channel selection

Temparature sensor output voltage

Conversion time mode

Normal 1

Conversion time

544/fCLK 22.6667(μ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_cg_main.c

void main(void)

{

       R_MAIN_UserInit();

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

       /* Start the temperature sensor operation */

       R_TMPS_Start();

 

       /* 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_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();

 

       /* Return the higher 8 bits conversion result */

       R_ADC_Get_Result_8bit((uint8_t *)&g_adc_value);

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

}