User`s manual
RX62N Group, RX621 Group 5. Usage Examples
5.16.2. ADC Self-Diagnostic function
Figure 5-39 shows a usage example of ADC Self-Diagnostic function.
ADC unit 0 is set to get the A/D conversion of Vref x 1 voltage value.
ADC unit 1 is set to get the A/D conversion of Vref x 0 voltage value.
/* PDL functions */
#include "r_pdl_adc_10.h"
#include "r_pdl_cgc.h"
#include "r_pdl_intc.h"
/* PDL device-specific definitions */
#include "r_pdl_definitions.h"
void ADC0_callback(void);
volatile uint8_t adc0_complete;
uint16_t result_adc0;
uint16_t result_adc1;
void main(void)
{
/* Configure the clocks */
R_CGC_Set(
12E6,
96E6,
48E6,
0,
PDL_CGC_BCLK_HIGH
);
/* Configure ADC unit 0 */
R_ADC_10_Create(
0,
PDL_ADC_10_SELF_DIAGNOSTIC_VREF_1,
12E6,
20E-6,
ADC0_callback,
7
);
/* Configure ADC unit 1 */
R_ADC_10_Create(
1,
PDL_ADC_10_SELF_DIAGNOSTIC_VREF_0,
48E6,
0.5E-6,
PDL_NO_FUNC,
0
);
adc0_complete = false;
/* Start ADC0 */
R_ADC_10_Control(PDL_ADC_10_0_ON | PDL_ADC_10_CPU_ON);
/* Start ADC1 and wait for it to complete */
R_ADC_10_Control(PDL_ADC_10_1_ON);
/* Fetch the result */
R_ADC_10_Read(
1,
&result_adc1
);
/* Wait for ADC0 to complete */
while (adc0_complete == false);
R20UT0084EE0112 Rev.1.12 Page 5-73
July. 16, 2014