RX Family
ADC Module Using Firmware Integration Technology
R01AN1666EJ0220 Rev. 2.20
Page 67 of 74
Dec 01, 2016
3.4
R_ADC_Read()
This function reads conversion results from a single channel, sensor, double trigger, or self-diagnosis register.
Format
adc_err_t R_ADC_Read(uint8_t unit,
adc_reg_t const reg_id,
uint16_t * const p_data);
Parameters
unit
0 or 1. For MCUs with only one unit 0 should be passed (only the RX64M/RX71M/RX65x have 2 units).
reg_id
Id for the register to read. See type
adc_reg_t
in section 2.10 for the MCU being used.
p_data
Pointer to variable to load value into.
Return Values
ADC_SUCCESS:
Success
ADC_ERR
_
INVALID_ARG:
unit or reg_id contains an invalid value.
ADC_ERR_MISSING _PTR:
p_data is FIT_NO_PTR/NULL
Properties
Prototyped in file “r_s12ad_rx_if.h”
Description
Reads conversion results from a single channel, sensor, double trigger, or self-diagnosis register.
Reentrant
Yes.
Example
uint16_t data;
:
/* Read channel 0 on unit 0 */
R_ADC_Read(0, ADC_CH0_REG, &data); // conversion value placed in “data”
Special Notes (RX110/RX111/RX113):
For temperature sensor output and internal reference voltage, discard the first A/D conversion result after the open, and
use the second and the subsequent A/D conversion results.