This module provides support for all features of the 12-bit A/D Converter on the RX110, RX111, RX113, RX130,
RX210, RX230, RX231, RX631, RX63N, RX64M, RX65N and RX71M.
Target Device
The following is a list of devices that are currently supported by this API:
• RX110, RX111, RX113, RX130 Groups
• RX210 Group
• RX230, RX231 Groups
• RX631, RX63N Groups
• RX64M Group
• RX65N Group
• RX71M Group
When using this application note with other Renesas MCUs, careful evaluation is recommended after making
modifications to comply with the alternate MCU.
5.7 Adding a Demo to a Workspace ..................................................................................................... 73
R01AN1666EJ0220 Rev. 2.20 Page 2 of 74
Dec 01, 2016
RX Family ADC Module Using Firmware Integration Technology
1. Overview
This A/D Converter (ADC) driver supports the S12ADa peripheral on the RX63x, the S12ADb peripheral on the
RX11x/RX210, the S12ADC peripheral on the RX64M/RX71M, the S12ADE peripheral on the RX130/RX230/RX231
and the S12ADFa peripheral on the RX65x.
Depending on the MCU chosen, some features include, but are not limited to single scans, grouped single scans, and
continuous scanning. Peripheral features include register left or right alignment, clearing data after register reads,
summation and average of conversion results, and the ability to store data on alternate triggers of a channel. Channel,
temperature and internal reference voltage sensor specific features include setting sampling time using state counts, and
opting out of summation of samples. There is no dependency on any other software except for the board support
package (r_bsp module).
The ADC begins conversion when it receives a trigger. When the conversion is complete, a flag is set and an interrupt
issued if enabled. If the ADC is operating in a single scan mode, only one scan takes place per trigger. If the ADC is
operating in a continuous mode, scans continue indefinitely after the initial trigger occurs.
The trigger source may be synchronous from an MTU peripheral, Event Link Controller (ELC), or a TPU peripheral
(non-RX11x); asynchronous from an external trigger on ADTRG#, or from setting a bit in software. Note that even
though a software trigger is an asynchronous action, the hardware manual reserves the term “asynchronous trigger” to
refer to asynchronous external hardware triggers. Additionally, although the temperature sensor on the RX210 has its
own independent trigger, the driver hides this operation and the application should be written as if the standard software
trigger is being used.
The driver provides a Control() command for polled applications which checks to see if a scan completed after a trigger
occurs. If interrupts are in use, the interrupt will call a Callback function specified in the Open() function. The only
argument to the Callback function specifies whether the default scan has completed or a Group B scan has completed.
In general, the peripheral operates on a single trigger source. However, in a group mode, two different trigger sources
are used. Each group can contain one or more unique channels and may be scanned at different trigger intervals.
The majority of the driver serves to initialize the A/D peripheral and provide functions to read conversion results.
Settings which are common to all channels such as conversion alignment or addition count are set in the Open() call.
Specific channel enabling is done via a Control() command. Two Read() functions are provided- one which retrieves a
single conversion value and another which retrieves all conversion registers whether the channel is enabled or not.
For the RX11x/RX21x/RX63x there are 13 to 24 channels available for conversion depending upon the MCU chosen.
All MCUs include a Temperature and an Internal Reference Voltage sensor. Each has its own conversion register. In
addition, in non-RX63x MCUs, a single channel can be designated as a “double trigger”. This means the scan-complete
flag/interrupt occurs on every other scan. On an odd scan, the conversion result is placed in its normal data register. On
an even scan, the result is placed in a special register. Double trigger cannot be used with sensors or other channels
(unless the other channels are in Group B), and a sensor can only be scanned by itself.
For the RX64M/RX71M/RX65x there are 8 channels on Unit 0, 21 channels and two sensors (Temperature and Internal
Reference Voltage) on Unit 1. In addition, a single channel on each unit can be designated as a “double trigger”
channel. This means that the scan-complete flag/interrupt occurs on every other scan. On an odd scan, the conversion
result is placed in its normal data register. On an even scan, the result is placed in a special register. Double trigger
cannot be used with sensors or other channels (unless the other channels are in other Groups.). Sensors and channels
may be scanned together on Unit 1. A built-in level and window comparator is available for channels and sensors. The
sensors are available on unit 1 and a Sample & Hold feature is available on unit 0 for sampling up to 3 channels
simultaneously. A virtual channel is available for Self-Diagnosis against various voltages, and a Disconnect Detection
Assist feature allows for an initial charging or discharging of the internal capacitor. This 12-bit converter may also be
configured for 8 or 10-bit resolution for slightly faster conversion if desired, and an input is available for an external
amplifier (positive or negative gain) for up to 8 channels on unit 1.
R01AN1666EJ0220 Rev. 2.20 Page 3 of 74
Dec 01, 2016
RX Family ADC Module Using Firmware Integration Technology
2. API Information
This Driver API follows the Renesas API naming standards.
2.1 Hardware Requirements
This driver requires your MCU support the following features:
•S12ADa, S12ADb, S12ADC, S12ADE or S12ADFa peripheral
2.2 Hardware Resource Requirements
This section details the hardware peripherals that this driver requires. Unless explicitly stated, these resources must be
reserved for the driver and the user cannot use them.
2.2.1 S12ADa/S12ADb/S12ADC/S12ADE/S12ADFa
This driver makes use of all features available on these peripherals.
2.2.2 GPIO
This driver utilizes port pins corresponding to each individual analog channel. These pins may not be used for GPIO.
2.3 Software Requirements
This driver is dependent upon the following packages:
•Renesas Board Support Package (r_bsp)
2.4 Limitations
Registers, settings, or usage notes vary depending on the mode used in the 12-bit A/D converter. APIs in this
application note must be used according to the 12-bit A/D converter chapter in the User's Manual: Hardware for the
MCU used.
2.5 Supported Toolchains
This driver is tested and working with the following toolchains:
•Renesas RX Toolchain v2.05.00
2.6 Header Files
Compile time configurable options are located in r_s12ad_rx\ref\r_s12ad_rx_config_reference.h. This file should be
copied into the r_config subdirectory of the project and renamed to r_s12ad_rx_config.h. It is this renamed file that
should be modified if needed and the original kept as a reference.
All API calls and their supporting interface definitions are located in r_s12ad_rx\r_s12ad_rx_if.h. Both this file and
r_s12ad_rx_config.h should be included by the User’s application.
2.7 Integer Types
This project uses ANSI C99 “Exact width integer types” in order to make the code clearer and more portable. These
types are defined in stdint.h.
R01AN1666EJ0220 Rev. 2.20 Page 4 of 74
Dec 01, 2016
RX Family ADC Module Using Firmware Integration Technology
If this equate is set to 1, parameter checking is included
utilizes the system default setting.
// 1.8V <= AVcc0 < 2.7V
This equate is for the Temperature Sensor gain
2.8 Configuration Overview
All configurable options that can be set at build time are located in the file “r_s12ad_rx_config.h”. A summary of these
settings are provided in the following table:
in the build. If the equate is set to 0, the parameter
checking is omitted from the build. Setting this equate
to BSP_CFG_PARAM_CHECKING_ENABLE
amplifier on the RX210. The default is a value of 0
which is good for all target voltages. For best
temperature resolution, the voltage range which most
accurately reflects the AVcc0 should have its #define
uncommented.
2.9 Code Size
The code size is based on optimization level 2 and optimization type for size for the RXC toolchain in Section 2.5. The
ROM (code and constants) and RAM (global data) sizes are determined by the build-time configuration options set in
the module configuration header file.
With Parameter CheckingWithout Parameter Checking
ROM: 1354 bytes ROM: 983 bytes
RX110
RAM: 12 bytes RAM: 12 bytes
ROM: 1234 bytes ROM: 950 bytes
RX111
RAM: 124 bytes RAM: 124 bytes
ROM: 1471 bytes ROM: 1100 bytes
RX113
RAM: 12 bytes RAM: 12 bytes
ROM: 2560 bytes ROM: 1879 bytes
RX130
RAM: 12 bytes RAM: 12 bytes
ROM: 1671 bytes ROM: 1200 bytes
RX210
RAM: 12 bytes RAM: 12 bytes
ROM and RAM code sizes
R01AN1666EJ0220 Rev. 2.20 Page 5 of 74
Dec 01, 2016
RX Family ADC Module Using Firmware Integration Technology
ROM: 2327 bytes ROM: 1616 bytes
RX230, RX231
RAM: 12 bytes RAM: 12 bytes
ROM: 1030 bytes ROM: 792 bytes
RX63N
RAM: 12 bytes RAM: 12 bytes
ROM: 3277 bytes ROM: 2464 bytes
RX64M
RAM: 32 bytes RAM: 32 bytes
ROM: 5176 bytes ROM: 4114 bytes
RX65N
RAM: 40 bytes RAM: 40 bytes
ROM: 3277 bytes ROM: 2464 bytes
RX71M
RAM: 32 bytes RAM: 32 bytes
Table 2: ROM and RAM code size
2.10 API Data Structures
This section details the data structures that are used with the driver’s API functions.
To provide strong type checking and reduce errors, many parameters used in API functions require arguments to be
passed using the provided type definitions. Allowable values are defined in the public interface files:
/* ADC_OPEN() ARGUMENT DEFINITIONS */
typedef enum e_adc_mode
{
ADC_MODE_SS_TEMPERATURE, // single scan temperature sensor
ADC_MODE_SS_INT_REF_VOLT, // single scan internal ref voltage sensor
ADC_MODE_SS_ONE_CH, // single scan one channel
ADC_MODE_SS_MULTI_CH, // 1 trigger source, scan multiple channels
ADC_MODE_CONT_ONE_CH, // continuous scan one channel
ADC_MODE_CONT_MULTI_CH, // continuous scan multiple channels
ADC_MODE_SS_ONE_CH_DBLTRIG, // on even trig save to ADDBLDR & interrupt
ADC_MODE_SS_MULTI_CH_GROUPED, // 2 trigger sources, scan multiple channels
ADC_MODE_SS_MULTI_CH_GROUPED_DBLTRIG_A,
ADC_MODE_MAX // This definition DO NOT USE for R_ADC_Open() argument
} adc_mode_t;
typedefenum e_adc_trig // trigger sources (set to TRSA bit or TRSB bit)
{
ADC_TRIG_ASYNC_ADTRG = 0, // ext asynchronous trigger; not for
// Group modes nor double trigger modes
ADC_TRIG_SYNC_TRG0AN = 1, // MTU0 TRGA
ADC_TRIG_SYNC_TRG0BN = 2, // MTU0 TRGB
ADC_TRIG_SYNC_TRGAN = 3, // MTUx TRGA
R01AN1666EJ0220 Rev. 2.20 Page 7 of 74
Dec 01, 2016
RX Family ADC Module Using Firmware Integration Technology
adc_add_t add_cnt;
adc_align_t alignment; // ignored if addition used
adc_clear_t clearing;
adc_speed_t conv_speed;
adc_trig_t trigger; // default and Group A trigger source
adc_trig_t trigger_groupb; // valid only for group modes
uint8_t priority; // for S12ADIO int; 1=lo 15=hi 0=off/polled
uint8_t priority_groupb; // GBADI interrupt priority; 0-15
} adc_cfg_t;
/* ADC_CONTROL() ARGUMENT DEFINITIONS */
typedefenume_adc_cmd
{
// Commands for special hardware configurations
ADC_CMD_SET_SAMPLE_STATE_CNT,
// Commands to enable channels or sensors
ADC_CMD_ENABLE_CHANS, // enables chans and A & B INT if pri != 0
ADC_CMD_ENABLE_TEMP_SENSOR, // enables sensor and INT if priority != 0
ADC_CMD_ENABLE_VOLT_SENSOR, // enables sensor and INT if priority != 0
// Commands to enable hardware triggers or cause software trigger
ADC_CMD_ENABLE_TRIG, // ADCSR.TRGE=1 for sync/async triggers
ADC_CMD_SCAN_NOW, // software trigger start scan
R01AN1666EJ0220 Rev. 2.20 Page 8 of 74
Dec 01, 2016
RX Family ADC Module Using Firmware Integration Technology
// Commands to poll for scan completion
ADC_CMD_CHECK_SCAN_DONE, // for Normal or GroupA scan
ADC_CMD_CHECK_SCAN_DONE_GROUPA,
ADC_CMD_CHECK_SCAN_DONE_GROUPB,
/* ADC_OPEN() ARGUMENT DEFINITIONS */
typedef enum e_adc_mode
{
ADC_MODE_SS_TEMPERATURE, // single scan temperature sensor
ADC_MODE_SS_INT_REF_VOLT, // single scan internal ref voltage sensor
ADC_MODE_SS_ONE_CH, // single scan one channel
ADC_MODE_SS_MULTI_CH, // 1 trigger source, scan multiple channels
ADC_MODE_CONT_ONE_CH, // continuous scan one channel
ADC_MODE_CONT_MULTI_CH, // continuous scan multiple channels
ADC_MODE_SS_ONE_CH_DBLTRIG, // on even trig save to ADDBLDR & interrupt
ADC_MODE_SS_MULTI_CH_GROUPED, // 2 trigger sources, scan multiple channels
ADC_MODE_SS_MULTI_CH_GROUPED_DBLTRIG_A,
ADC_MODE_MAX // This definition DO NOT USE for R_ADC_Open() argument
} adc_mode_t;
typedef enum e_adc_trig // trigger sources (set to TRSA bit or TRSB bit)
{
ADC_TRIG_ASYNC_ADTRG = 0, // ext asynchronous trigger; not for Group modes// nor double trigger modes
R01AN1666EJ0220 Rev. 2.20 Page 10 of 74
Dec 01, 2016
RX Family ADC Module Using Firmware Integration Technology
adc_add_t add_cnt;
adc_align_t alignment; // ignored if addition used
adc_clear_t clearing;
adc_speed_t conv_speed;
adc_trig_t trigger; // default and Group A trigger source
adc_trig_t trigger_groupb; // valid only for group modes
uint8_t priority; // for S12ADIO int; 1=lo 15=hi 0=off/polled
uint8_t priority_groupb;// GBADI interrupt priority; 0-15
} adc_cfg_t;
/* ADC_CONTROL() ARGUMENT DEFINITIONS */
typedefenume_adc_cmd
{
// Commands for special hardware configurations
ADC_CMD_SET_SAMPLE_STATE_CNT,
R01AN1666EJ0220 Rev. 2.20 Page 11 of 74
Dec 01, 2016
RX Family ADC Module Using Firmware Integration Technology
// Commands to enable channels or sensors
ADC_CMD_ENABLE_CHANS, // enables chans and A & B INT if pri != 0
ADC_CMD_ENABLE_TEMP_SENSOR, // enables sensor and INT if priority != 0
ADC_CMD_ENABLE_VOLT_SENSOR, // enables sensor and INT if priority != 0
// Commands to enable hardware triggers or cause software trigger
ADC_CMD_ENABLE_TRIG, // ADCSR.TRGE=1 for sync/async triggers
ADC_CMD_SCAN_NOW, // software trigger start scan
// Commands to poll for scan completion
ADC_CMD_CHECK_SCAN_DONE, // for Normal or GroupA scan
ADC_CMD_CHECK_SCAN_DONE_GROUPA,
ADC_CMD_CHECK_SCAN_DONE_GROUPB,
adc_add_t add_cnt;
adc_align_t alignment; // ignored if addition used
adc_clear_t clearing;
adc_speed_t conv_speed;
adc_trig_t trigger; // default and Group A trigger source
adc_trig_t trigger_groupb; // valid only for group modes
uint8_t priority; // for S12ADIO int; 1=lo 15=hi 0=off/polled
uint8_t priority_groupb; // GBADI interrupt priority; 0-15
R01AN1666EJ0220 Rev. 2.20 Page 14 of 74
Dec 01, 2016
RX Family ADC Module Using Firmware Integration Technology
} adc_cfg_t;
/* ADC_CONTROL() ARGUMENT DEFINITIONS */
typedefenume_adc_cmd
{
// Commands for special hardware configurations
ADC_CMD_USE_INT_VOLT_AS_HVREF,
ADC_CMD_SET_SAMPLE_STATE_CNT,
// Commands to enable channels or sensors
ADC_CMD_ENABLE_CHANS, // enables chans and A & B INT if pri != 0
ADC_CMD_ENABLE_TEMP_SENSOR, // enables sensor and INT if priority != 0
ADC_CMD_ENABLE_VOLT_SENSOR, // enables sensor and INT if priority != 0
// Commands to enable hardware triggers or cause software trigger
ADC_CMD_ENABLE_TRIG, // ADCSR.TRGE=1 for sync/async triggers
ADC_CMD_SCAN_NOW, // software trigger start scan
// Commands to poll for scan completion
ADC_CMD_CHECK_SCAN_DONE, // for Normal or GroupA scan
ADC_CMD_CHECK_SCAN_DONE_GROUPA,
ADC_CMD_CHECK_SCAN_DONE_GROUPB,
R01AN1666EJ0220 Rev. 2.20 Page 16 of 74
Dec 01, 2016
RX Family ADC Module Using Firmware Integration Technology
typedefstructst_adc_data
{
uint16_t chan[ADC_REG_ARRAY_MAX]; // chnls/indexes used depends upon MCU
uint16_t temp;
uint16_t volt;
uint16_t dbltrig; // Not used on RX63x
} adc_data_t;
2.10.5 RX130 Interface Types (r_s12ad_rx130_if.h)
/***** ADC_OPEN() ARGUMENT DEFINITIONS *****/
typedef enum e_adc_mode
{
ADC_MODE_SS_TEMPERATURE, // single scan temperature sensorADC_MODE_SS_INT_REF_VOLT, // single scan internal ref voltage sensorADC_MODE_SS_ONE_CH, // single scan one channelADC_MODE_SS_MULTI_CH, // 1 trigger source, scan multiple channelsADC_MODE_CONT_ONE_CH, // continuous scan one channelADC_MODE_CONT_MULTI_CH, // continuous scan multiple channelsADC_MODE_SS_ONE_CH_DBLTRIG, // on even triggers save to ADDBLDR &
ADC_TRIG_SOFTWARE = 10, // software trigger; not for Group modes// nor double trigger modes // This is not set to TRSA or TRSB
ADC_TRIG_NONE = 0x3F
} adc_trig_t;
adc_trig_ttrigger; // ADSTRGR.TRSA, default and Group A
trigger source
adc_trig_ttrigger_groupb; // valid only for group modesuint8_tpriority; // for S12ADIO int; 1=lo 15=hi 0=off/polleduint8_tpriority_groupb; // S12GBADI interrupt priority; 0-15
} adc_cfg_t;
/***** ADC_CONTROL() ARGUMENT DEFINITIONS *****/
typedef enum e_adc_cmd
{
// Commands for special hardware configurationsADC_CMD_USE_VREFL0, // Low reference. Default is to use AVSS0.ADC_CMD_USE_VREFH0, // High reference. Default is to use AVCC0.ADC_CMD_SET_DDA_STATE_CNT, // For Disconnect Detection AssistADC_CMD_SET_SAMPLE_STATE_CNT, // Set the conversion time
// Command to configure channels, sensors, and comparatorADC_CMD_ENABLE_CHANS, // Configure channels to scanADC_CMD_ENABLE_TEMP_SENSOR, // "configure" temperature sensorADC_CMD_ENABLE_VOLT_SENSOR, // "configure" internal ref voltage sensorADC_CMD_EN_COMPARATOR_LEVEL, // Enable comparator for threshold compareADC_CMD_EN_COMPARATOR_WINDOW, // Enable comparator for range compare
// Commands to enable hardware triggers or cause software triggerADC_CMD_ENABLE_TRIG, // ADCSR.TRGE=1 for sync/asynchronous
triggers
ADC_CMD_SCAN_NOW, // Software trigger start scan
// Commands to poll for scan completion and comparator results
R01AN1666EJ0220 Rev. 2.20 Page 18 of 74
Dec 01, 2016
RX Family ADC Module Using Firmware Integration Technology
ADC_CMD_CHECK_SCAN_DONE, // For Normal or GroupA scanADC_CMD_CHECK_SCAN_DONE_GROUPA,
ADC_CMD_CHECK_SCAN_DONE_GROUPB,
ADC_CMD_CHECK_CONDITION_MET, // comparator condition
{
adc_sst_reg_treg_id;
uint8_tnum_states; // ch16-21, 24-26 use the same value
} adc_sst_t;
R01AN1666EJ0220 Rev. 2.20 Page 19 of 74
Dec 01, 2016
RX Family ADC Module Using Firmware Integration Technology
/* for ADC_CMD_CONFIGURE_SCAN */
// Bitwise OR these masks together for desired channels and sensors
// Used for all commands containing a "mask" or "flags" field
{
ADC_ELC_SCAN_DONE = 0, // normal scan or Group A scan completeADC_ELC_GROUPB_SCAN_DONE,
ADC_ELC_ALL_SCANS_DONE,
} adc_elc_t;
typedef struct st_adc_ch_cfg
{
uint32_tchan_mask; // channels/bits 0-7, 16-21, 24-26uint32_tchan_mask_groupb; // valid for group modesadc_grpa_tpriority_groupa; // valid for group modes
R01AN1666EJ0220 Rev. 2.20 Page 20 of 74
Dec 01, 2016
RX Family ADC Module Using Firmware Integration Technology
uint32_tadd_mask; // valid if add enabled in Open()adc_diag_tdiag_method; // self-diagnosis virtual channeladc_elc_tsignal_elc; //
} adc_ch_cfg_t;
/* for ADC_CMD_EN_COMPARATOR_LEVEL and ADC_CMD_EN_COMPARATOR_WINDOW */
typedef struct st_adc_cmpwin_cfg // bit-OR ADC_MASK_xxx to
{ // indicate channels/sensors
uint32_tcompare_mask; // channels/sensors to compare
uint32_t inside_window_mask; // condition met when within range
// default=0 met when outside range
uint16_tlevel_lo; // Low-value of window
uint16_tlevel_hi; // High-value of window boolwindowa_enable; // comparison window A enable
} adc_cmpwin_t;
/* for ADC_CMD_CHECK_CONDITION_MET use uint32_t */
/***** ADC_READ() ARGUMENT DEFINITIONS *****/
typedef enum e_adc_reg
{
ADC_REG_CH0 = 0, // Channel 0ADC_REG_CH1,
ADC_REG_CH2,
ADC_REG_CH3,
ADC_REG_CH4,
ADC_REG_CH5,
ADC_REG_CH6,
ADC_REG_CH7, // Channel 7ADC_REG_CH16, // Channel 16ADC_REG_CH17,
ADC_REG_CH18,
ADC_REG_CH19,
ADC_REG_CH20,
ADC_REG_CH21,
ADC_REG_CH24,
ADC_REG_CH25,
ADC_REG_CH26,
ADC_REG_TEMP, // A/D Temperature sensor outputADC_REG_VOLT, // A/D Internal Voltage ReferenceADC_REG_DBLTRIG, // Data Duplication registerADC_REG_DBLTRIGA, // loaded when first multi-source trigger was AADC_REG_DBLTRIGB, // loaded when first multi-source trigger was BADC_REG_SELF_DIAG, // self-diagnosis registerADC_REG_MAX = ADC_REG_SELF_DIAG
} adc_reg_t;
R01AN1666EJ0220 Rev. 2.20 Page 21 of 74
Dec 01, 2016
RX Family ADC Module Using Firmware Integration Technology
2.10.6 RX210 Interface Types (r_s12ad_rx210_if.h)
/* ADC_OPEN() ARGUMENT DEFINITIONS */
typedefenume_adc_mode
{
ADC_MODE_SS_TEMPERATURE, // single scan temperature sensor
ADC_MODE_SS_INT_REF_VOLT, // single scan internal ref voltage sensor
ADC_MODE_SS_ONE_CH, // single scan one channel
ADC_MODE_SS_MULTI_CH, // 1 trigger source, scan multiple channels
ADC_MODE_CONT_ONE_CH, // continuous scan one channel
ADC_MODE_CONT_MULTI_CH, // continuous scan multiple channels
ADC_MODE_SS_ONE_CH_DBLTRIG, // on even trig save to ADDBLDR & interrupt
ADC_MODE_SS_MULTI_CH_GROUPED, // 2 trigger sources, scan multiple channels
ADC_MODE_SS_MULTI_CH_GROUPED_DBLTRIG_A,
ADC_MODE_MAX // This definition DO NOT USE for R_ADC_Open() argument
} adc_mode_t;
typedefenum e_adc_trig // trigger sources (set to TRSA bit or TRSB bit)
{
ADC_TRIG_ASYNC_ADTRG = 0, // ext asynchronous trigger; not for Group
// modes nor double trigger modes
ADC_TRIG_SYNC_TRG0AN = 1, // MTU0 TRGA
ADC_TRIG_SYNC_TRG0BN = 2, // MTU0 TRGB
ADC_TRIG_SYNC_TRGAN_OR_UDF4N = 3, // MTUx TRGA or MTU4 underflow
ADC_TRIG_SOFTWARE = 16 // software trigger; not for Group modes
// nor double trigger modes
// This is not set to TRSA or TRSB
} adc_trig_t;
typedefenume_adc_add
{
ADC_ADD_OFF = 0, // addition is turned off for chans/sensors
// add not allowed for temperature sensor
ADC_ADD_TWO_SAMPLES = 1,
ADC_ADD_THREE_SAMPLES = 2,
ADC_ADD_FOUR_SAMPLES = 3
R01AN1666EJ0220 Rev. 2.20 Page 22 of 74
Dec 01, 2016
RX Family ADC Module Using Firmware Integration Technology
typedefstructst_adc_cfg
{
adc_add_t add_cnt;
adc_align_t alignment; // ignored if addition used
adc_clear_t clearing;
adc_trig_t trigger; // default and Group A trigger source
adc_trig_t trigger_groupb; // valid only for group modes
uint8_t priority; // for S12ADIO int; 1=lo 15=hi 0=off/polled
uint8_t priority_groupb; // GBADI interrupt priority; 0-15
} adc_cfg_t;
/* ADC_CONTROL() ARGUMENT DEFINITIONS */
typedefenume_adc_cmd
{
// Commands for special hardware configurations
ADC_CMD_SET_DDA_STATE_CNT, // for Disconnect Detection Assist
ADC_CMD_SET_SAMPLE_STATE_CNT,
// Commands to enable channels or sensors
ADC_CMD_ENABLE_CHANS, // enables chans and A & B INT if pri != 0
ADC_CMD_ENABLE_TEMP_SENSOR, // enables sensor and INT if priority != 0
ADC_CMD_ENABLE_VOLT_SENSOR, // enables sensor and INT if priority != 0
// Commands to enable hardware triggers or cause software trigger
ADC_CMD_ENABLE_TRIG, // ADCSR.TRGE=1 for sync/async triggers
ADC_CMD_SCAN_NOW, // software trigger start scan
// Commands to poll for scan completion
ADC_CMD_CHECK_SCAN_DONE, // for Normal or GroupA scan
ADC_CMD_CHECK_SCAN_DONE_GROUPA,
ADC_CMD_CHECK_SCAN_DONE_GROUPB,
uint16_t chan[ADC_REG_ARRAY_MAX];
uint16_t temp;
uint16_t volt;
uint16_t dbltrig;
uint16_t self_diag;
} adc_data_t;
2.10.7 RX230 Interface Types (r_s12ad_rx230_if.h)
/***** ADC_OPEN() ARGUMENT DEFINITIONS *****/
typedefenume_adc_mode
{
ADC_MODE_SS_TEMPERATURE, // single scan temperature sensor
ADC_MODE_SS_INT_REF_VOLT, // single scan internal ref voltage sensor
ADC_MODE_SS_ONE_CH, // single scan one channel
ADC_MODE_SS_MULTI_CH, // 1 trigger source, scan multiple channels
ADC_MODE_CONT_ONE_CH, // continuous scan one channel
ADC_MODE_CONT_MULTI_CH, // continuous scan multiple channels
R01AN1666EJ0220 Rev. 2.20 Page 25 of 74
Dec 01, 2016
RX Family ADC Module Using Firmware Integration Technology
ADC_MODE_SS_ONE_CH_DBLTRIG, // on even triggers save to ADDBLDR &
// interrupt
ADC_MODE_SS_MULTI_CH_GROUPED, // 2 trigger sources, scan multiple channels
ADC_MODE_SS_MULTI_CH_GROUPED_DBLTRIG_A,
ADC_MODE_MAX // This definition DO NOT USE for R_ADC_Open() argument
} adc_mode_t;
ADC_TRIG_SOFTWARE = 15, // software trigger; not for Group modes
// nor double trigger modes
// This is not set to TRSA or TRSB
ADC_TRIG_NONE = 0x3F
} adc_trig_t;
adc_trig_t trigger; // ADSTRGR.TRSA, default and Group A
// trigger source
adc_trig_t trigger_groupb; // valid only for group modes
uint8_t priority; // for S12ADIO int; 1=lo 15=hi 0=off/polled
uint8_t priority_groupb; // S12GBADI interrupt priority; 0-15
} adc_cfg_t;
/***** ADC_CONTROL() ARGUMENT DEFINITIONS *****/
typedefenume_adc_cmd
{
// Commands for special hardware configurations
ADC_CMD_USE_VREFL0, // Low reference. Default is to use AVSS0.
ADC_CMD_USE_VREFH0, // High reference. Default is to use AVCC0.
ADC_CMD_SET_DDA_STATE_CNT, // For Disconnect Detection Assist
ADC_CMD_SET_SAMPLE_STATE_CNT, // Set the conversion time
// Command to configure channels, sensors, and comparator
ADC_CMD_ENABLE_CHANS, // Configure channels to scan
ADC_CMD_ENABLE_TEMP_SENSOR, // "configure" temperature sensor
ADC_CMD_ENABLE_VOLT_SENSOR, // "configure" internal ref voltage sensor
ADC_CMD_EN_COMPARATOR_LEVEL, // Enable comparator for threshold compare
ADC_CMD_EN_COMPARATOR_WINDOW, // Enable comparator for range compare
// Commands to enable hardware triggers or cause software trigger
ADC_CMD_ENABLE_TRIG, // ADCSR.TRGE=1 for sync/asynchronous
// triggers
ADC_CMD_SCAN_NOW, // Software trigger start scan
// Commands to poll for scan completion and comparator results
ADC_CMD_CHECK_SCAN_DONE, // For Normal or GroupA scan
ADC_CMD_CHECK_SCAN_DONE_GROUPA,
ADC_CMD_CHECK_SCAN_DONE_GROUPB,
ADC_CMD_CHECK_CONDITION_MET, // comparator condition