EasyManuals Logo

Renesas RX110 User Manual

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
Page #58 background imageLoading...
Page #58 background image
RX Family ADC Module Using Firmware Integration Technology
R01AN1666EJ0220 Rev. 2.20 Page 58 of 74
Dec 01, 2016
Example 2: Temperature Sensor Polling and Set Sample State Count Unit 1 (RX64M, RX71M,
RX65x)
uint16_t data;
adc_cfg_t config;
adc_sst_t sst; // sample state
adc_ch_cfg_t ch_cfg;
adc_err_t adc_err;
/* OPEN ADC */
/* Clear all fields of the adc_cfg_t structure */
memset(&config, 0, sizeof(config));
/* Open ADC for software trigger, single scan temperature sensor, and polling */
config.resolution = ADC_RESOLUTION_10_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;
adc_err = R_ADC_Open(1, ADC_MODE_SS_ONE_CH, &config, NULL);
/* DO SPECIAL HARDWARE CONFIGURATION */
/* Clear all fields of the adc_sst_t structure */
memset(&sst, 0, sizeof(sst));
/* Clear all fields of the adc_ch_cfg_t structure */
memset(&ch_cfg, 0, sizeof(ch_cfg));
/* Set number of sampling states for 4us sample *
/* For PCLKD=60MHz, 1 state = 1/60MHz = 16.7ns, 4us/16.7ns = 240 states */
sst.reg_id = ADC_SST_TEMPERATURE;
sst.num_states = 240;
adc_err = R_ADC_Control(1, ADC_CMD_SET_SAMPLE_STATE_CNT, &sst);
/* CONFIGURE SCAN */
ch_cfg.chan_mask = ADC_MASK_TEMP;
ch_cfg.diag_method = ADC_DIAG_OFF;
ch_cfg.anex_enable = false;
ch_cfg.sample_hold_mask = 0; // not available on unit 1
adc_err = R_ADC_Control(1, ADC_CMD_ENABLE_CHANS, &ch_cfg);
/* After open, wait 1 us or longer before A/D conversion starts */
/* CAUSE SOFTWARE TRIGGER */
adc_err = R_ADC_Control(1, ADC_CMD_SCAN_NOW, NULL);
/* WAIT FOR SCAN TO COMPLETE */
while (R_ADC_Control(1, ADC_CMD_CHECK_SCAN_DONE, NULL) == ADC_ERR_SCAN_NOT_DONE)
{
}
/* READ RESULT */
adc_err = R_ADC_Read(1, ADC_REG_TEMP, &data);

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Renesas RX110 and is the answer not in the manual?

Renesas RX110 Specifications

General IconGeneral
BrandRenesas
ModelRX110
CategoryControl Unit
LanguageEnglish

Related product manuals