EasyManua.ls Logo

Renesas RX110

Renesas RX110
88 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
RX Family ADC Module Using Firmware Integration Technology
R01AN1666EJ0220 Rev. 2.20 Page 61 of 74
Dec 01, 2016
/* Have channel 1 and 2 as Group A, have 3 and 4 as Group B,
have 5 and 6 as Group C
Perform addition/average on all channels except 9
*/
ch_cfg.scan_mask = ADC_MASK_CH1 | ADC_MASK_CH2;
ch_cfg.scan_mask_groupb = ADC_MASK_CH3 | ADC_MASK_CH4;
ch_cfg.scan_mask_groupc = ADC_MASK_CH5 | ADC_MASK_CH6;
ch_cfg.priority_groupa = ADC_GRPA_PRIORITY_OFF;
ch_cfg.add_mask = 0;
ch_cfg.diag_method = ADC_DIAG_OFF;
ch_cfg.anex_enable = false;
ch_cfg.sample_hold_mask = 0;
R_ADC_Control(0, ADC_CMD_CONFIGURE_SCAN, &ch_cfg);
/* After open, wait 1 us or longer before A/D conversion starts */
/* ENABLE TRIGGERS */
R_ADC_Control(0, ADC_CMD_ENABLE_TRIG, NULL);
/* INTERRUPT OCCURS UPON SCAN COMPLETION */
/* The callback is called twice from interrupt level- once after each
* group scan completes. The order depends upon the trigger order.
*/
void MyCallback(void *p_args)
{
adc_cb_args_t *args;
uint16_t data1,data2,data3,data4,data5,data6;
args = (adc_cb_args_t *)p_args;
/* READ RESULTS */
if (args->event == ADC_EVT_SCAN_COMPLETE)
{
/* From S12ADIO interrupt, Group A scan complete, read registers */
R_ADC_Read(0, ADC_REG_CH1, &data1);
R_ADC_Read(0, ADC_REG_CH2, &data2);
}
else if (args->event == ADC_EVT_SCAN_COMPLETE_GROUPB)
{
/* From GBADI interrupt, Group B scan complete, read registers */
R_ADC_Read(0, ADC_REG_CH3, &data3);
R_ADC_Read(0, ADC_REG_CH4, &data4);
}
else if (args->event == ADC_EVT_SCAN_COMPLETE_GROUPC)
{
/* From GCADI interrupt, Group C scan complete, read registers */
R_ADC_Read(0, ADC_REG_CH5, &data5);
R_ADC_Read(0, ADC_REG_CH6, &data6);
}
/* process data, or set flag for application level to do so */
}

Related product manuals