Start A/D conversion by External interrupt edge detection 0 of ELC event. Store A/D conversion result to RAM, then stop ELC.
[GUI setting example]
Event link controller |
Used | |||
ELC |
Used | |||
A/D conversion starts |
Used | |||
Event generation source |
External interrupt edge detection 0 |
Interrupt |
Used | |||
INTP |
Used | |||
INTP0 |
||||
Valid edge |
Falling | |||
Priority |
Low |
A/D convertor |
Used | |||
ADC |
Used | |||
A/D convertor operation setting |
Used | |||
Comparator operation setting |
Operation | |||
Resolution setting |
10 bits | |||
VREF(+) setting |
VDD | |||
VREF(-) setting |
VSS | |||
Trigger setting mode |
Hardware trigger no wait mode | |||
Hardware trigger no wait mode |
ELC | |||
Operation mode setting |
One-shot select mode | |||
ANI0 - ANI23 analog input selection |
ANI0 | |||
A/D channel selection |
ANI0 | |||
Conversion time mode |
Normal 1 | |||
Conversion time |
38 (1216/fCLK)(μs) | |||
Conversion result upper/lower bound value setting |
Generates an interrupt request (INTAD) when ADLL≦ADCRH≦ADUL | |||
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 include. Do not edit comment generated here */
#include "r_cg_elc.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_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 conversion result in the buffer */
R_ADC_Get_Result((uint16_t *)&g_adc_value);
/* Stop the ELC event resources */
R_ELC_Stop(0x00000001U);
/* End user code. Do not edit comment generated here */
}