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 57 of 74
Dec 01, 2016
Reentrant
Yes, but in general should not be used as such. A valid case for reentrancy would be in group mode with one task
performing the ADC_CMD_CHECK_SCAN_DONE_GROUPA and another performing the
ADC_CMD_CHECK_SCAN_DONE_GROUPB. Other commands such as enabling/disabling triggers or interrupts
would affect operations being performed by another task and reentrancy of this kind should be avoided.
Example 1: Single Channel Polling Unit 0 (RX64M, RX71M, RX65x only)
uint16_t data;
adc_cfg_t config;
adc_ch_cfg_t ch_cfg;
adc_err_t err;
/* OPEN ADC */
/* Clear all fields of the adc_cfg_t structure */
memset(&config, 0, sizeof(config));
/* Open ADC for software trigger, single scan of one channel, and polling */
config.resolution = ADC_RESOLUTION_12_BIT;
config.trigger = ADC_TRIG_SOFTWARE;
config.priority = 0; // denotes polling
config.add_cnt = ADC_ADD_OFF;
config.alignment = ADC_ALIGN_RIGHT;
config.clearing = ADC_CLEAR_AFTER_READ_OFF;
err = R_ADC_Open(0,ADC_MODE_SS_ONE_CH, &config, NULL);
/* ENABLE CHANNELS */
/* Clear all fields of the adc_ch_cfg_t structure */
memset(&ch_cfg, 0, sizeof(ch_cfg));
/* Specify and enable potentiometer channel on RSKRX64M */
ch_cfg.chan_mask = ADC_MASK_CH0;
ch_cfg.diag_method = ADC_DIAG_OFF;
ch_cfg.anex_enable = false;
ch_cfg.sample_hold_mask = 0;
err = R_ADC_Control(0, ADC_CMD_ENABLE_CHANS, &ch_cfg);
/* After open, wait 1 us or longer before A/D conversion starts */
/* Repeatedly trigger, poll for completion, and read result */
while(1)
{
/* CAUSE SOFTWARE TRIGGER */
err = R_ADC_Control(0, ADC_CMD_SCAN_NOW, NULL);
/* WAIT FOR SCAN TO COMPLETE */
while (R_ADC_Control(0,ADC_CMD_CHECK_SCAN_DONE,NULL) == ADC_ERR_SCAN_NOT_DONE)
{
}
/* READ RESULT */
err = R_ADC_Read(0, ADC_REG_CH0, &data);
}

Related product manuals