Driver for the and ADC12 peripherals on RZ microprocessor. This module implements the ADC Interface.
This module can be added to the Stacks tab via New Stack > Analog > ADC Driver on r_adc_e.
Configuration | Options | Default | Description |
General > Name | Name must be a valid C symbol | g_adc0 | Module name |
General > Unit | Unit must be a non-negative integer | 0 | Specifies the ADC Unit to be used. |
General > Resolution |
| 12-Bit | Specifies the conversion resolution for this unit. |
General > Clear after read |
| On | Specifies if the result register will be automatically cleared after the conversion result is read. |
General > Mode |
-
Single Scan
-
Continuous Scan
-
Group Scan
| Single Scan | Specifies the mode that this ADC unit is used in. |
General > Double-trigger |
-
Disabled
-
Enabled
-
Enabled (extended mode)
| Disabled | When enabled, the scan-end interrupt for Group A is only thrown on every second scan. Extended double-trigger mode (single-scan only) triggers on both ELC events, allowing (for example) a scan on two different timer compare match values.
In group mode Group B is unaffected.
|
Input > Start Trigger > Group A | Refer to the RZV Configuration tool for available options. | software | A/D Conversion Start Trigger Select for Group A. |
Input > Start Trigger > Group B | Refer to the RZV Configuration tool for available options. | Disabled | A/D Conversion Start Trigger Select for Group B. |
Input > Start Trigger > Group C Enabled |
| Disabled | Set to true to enable Group C, false to disable Group C. |
Input > Start Trigger > Group C | Refer to the RZV Configuration tool for available options. | Disabled | A/D Conversion Start Trigger Select for Group C. |
Input > Start Trigger > ELC Event | MCU Specific Options | | Select ELC event. |
Input > Window Compare > Window A > Enable |
| Disabled | Enable or disable comparison with Window A. |
Input > Window Compare > Window A > Channels to compare |
-
Channel 0
-
Channel 1
-
Channel 2
-
Channel 3
-
Channel 4
-
Channel 5
-
Channel 6
-
Channel 7
| | Select channels to be compared to Window A. |
Input > Window Compare > Window A > Channel comparison mode (channel availability varies by MCU and unit) |
-
Channel 0
-
Channel 1
-
Channel 2
-
Channel 3
-
Channel 4
-
Channel 5
-
Channel 6
-
Channel 7
| | Checking a box sets the comparison mode for that channel to Greater Than or Inside Window depending on whether Window Mode is disabled or enabled (respectively). If left unchecked the comparison mode will likewise be Less Than or Outside Window (respectively). |
Input > Window Compare > Window A > Lower Reference | Must be a positive 16-bit integer. | 0 | Set the lower comparison value. |
Input > Window Compare > Window A > Upper Reference | Must be a positive 16-bit integer. | 0 | Set the upper comparison value. |
Input > Window Compare > Window B > Enable |
| Disabled | Enable or disable comparison with Window B. |
Input > Window Compare > Window B > Channel to compare (channel availability varies by MCU and unit) |
-
Channel 0
-
Channel 1
-
Channel 2
-
Channel 3
-
Channel 4
-
Channel 5
-
Channel 6
-
Channel 7
| Channel 0 | Select a channel to be compared to Window B. |
Input > Window Compare > Window B > Comparison mode |
-
Less Than or Outside Window
-
Greater Than or Inside Window
| module.driver.adc_e.compare.window_b.mode | Select the comparison mode for Window B. For each option, the first condition applies when Window Mode is disabled and the second option applies when Window Mode is enabled. |
Input > Window Compare > Window B > Lower Reference | Must be a positive 16-bit integer. | 0 | Set the lower comparison value. |
Input > Window Compare > Window B > Upper Reference | Must be a positive 16-bit integer. | 0 | Set the upper comparison value. |
Input > Window Compare > Window Mode |
| Disabled | When disabled, ADC values will be compared only with the lower reference on each comparator. When enabled, both the lower and upper reference values will be used to create a comparison window. |
Input > Window Compare > Event Output |
| OR | Select how comparison results should be composited for event output. |
Input > Channel Scan Mask |
-
Channel 0
-
Channel 1
-
Channel 2
-
Channel 3
-
Channel 4
-
Channel 5
-
Channel 6
-
Channel 7
| | In Normal mode of operation, this bitmask field specifies the channels that are enabled in that ADC unit. In group mode, this field specifies which channels belong to group A. |
Input > Group B Scan Mask |
-
Channel 0
-
Channel 1
-
Channel 2
-
Channel 3
-
Channel 4
-
Channel 5
-
Channel 6
-
Channel 7
| | In group mode, this field specifies which channels belong to group B. |
Input > Group C Scan Mask |
-
Channel 0
-
Channel 1
-
Channel 2
-
Channel 3
-
Channel 4
-
Channel 5
-
Channel 6
-
Channel 7
| | In group mode, this field specifies which channels belong to group C. |
Input > Addition/Averaging Mask (channel availability varies by MCU and unit) |
-
Channel 0
-
Channel 1
-
Channel 2
-
Channel 3
-
Channel 4
-
Channel 5
-
Channel 6
-
Channel 7
| | Select channels to include in the Addition/Averaging Mask |
Input > Add/Average Count |
-
Disabled
-
Add 2 samples
-
Add 3 samples
-
Add 4 samples
-
Add 16 samples
-
Average 2 samples
-
Average 4 samples
| Disabled | Specifies if addition or averaging needs to be done for any of the channels in this unit. |
Input > Group Priority (Valid only in Group Scan Mode) |
-
Group A ignored and does not interrupt Group B and Group C
-
Group B and Group C restart at next trigger
-
Group B and Group C restart immediately and scans from the head of the channel
-
Group B and Group C restart immediately and scans
-
Group B and Group C restart and scans continuously from the head of the channel
-
Group B and Group C restart immediately and scans continuously from the head of the channel
-
Group B and Group C restart immediately and scans continuously
| Group A ignored and does not interrupt Group B and Group C | Determines whether an ongoing group B scan can be interrupted by a group A trigger, whether it should abort on a group A trigger, or if it should pause to allow group A scan and restart immediately after group A scan is complete. |
Interrupts > Callback | Name must be a valid C symbol | NULL | A user callback function. If this callback function is provided, it is called from the interrupt service routine (ISR) each time the ADC scan completes. |
Interrupts > Scan End Interrupt Enable | MCU Specific Options | | Enable or disable Scan End interrupt. |
Interrupts > Scan End Interrupt Priority | Value must be an integer between 0 and 255 | 12 | Select scan end interrupt priority. |
Interrupts > Scan End Group B Interrupt Enable | MCU Specific Options | | Enable or disable Scan End Group B interrupt. |
Interrupts > Scan End Group B Interrupt Priority | Value must be an integer between 0 and 255 | 12 | Select group B scan end interrupt priority. |
Interrupts > Scan End Group C Interrupt Enable | MCU Specific Options | | Enable or disable Scan End Group C interrupt. |
Interrupts > Scan End Group C Interrupt Priority | Value must be an integer between 0 and 255 | 12 | Select group C scan end interrupt priority. |
Interrupts > Window Compare A Interrupt Enable | MCU Specific Options | | Enable or disable Window Compare A interrupt. |
Interrupts > Window Compare A Interrupt Priority | Value must be an integer between 0 and 255 | 12 | Select group C scan end interrupt priority. |
Interrupts > Window Compare B Interrupt Enable | MCU Specific Options | | Enable or disable Window Compare B interrupt. |
Interrupts > Window Compare B Interrupt Priority | Value must be an integer between 0 and 255 | 12 | Select group C scan end interrupt priority. |
ELC > Output Event Signal |
-
Group A
-
Group B
-
Group A or B or C
-
Group C
| Group A | A/D Event Link Control. |
A/D conversion clock ADC_0_ADCLK is 50MHz, 40MHz, 20MHz, 10MHz or 5MHz.
The ANxxx pins are analog input channels that can be used with the ADC.
The driver supports three operation modes: single-scan, continuous-scan, and group-scan modes. In each mode, analog channels are converted in ascending order of channel number, followed by scans of the voltage sensor if they are included in the mask of channels to scan.
In single scan mode, one or more specified channels are scanned once per trigger.
In continuous scan mode, a single trigger is required to start the scan. Scans continue until R_ADC_E_ScanStop() is called.
Group-scan mode allows the application to allocate channels to one of two groups (A and B and C). Conversion begins when the specified ELC start trigger for that group is received.
The priority of group priority operations is group A > group B > group C. In group priority operation, if the scan start of group B is accepted during the scan of group C, the scan of group C is interrupted and the scan of group B is started. If the scan start of group A is accepted during the scan of group C, the scan of group A is started. The scan of Group C is interrupted and the scan of Group A is started. Similarly, if the scan start of Group A is accepted during the scan of Group B, the scan of Group B is interrupted and the scan of Group A is started.
When double-triggering is enabled a single channel is selected to be scanned twice before an interrupt is thrown. The first scan result when using double-triggering is always saved to the selected channel's data register. The second result is saved to the data duplexing register (ADC_CHANNEL_DUPLEX).
Double-triggering uses Group A; only one channel can be selected when enabled. No other scanning is possible on Group A while double-trigger mode is selected.
When extended double-triggering is enabled both ADC input events are routed to Group A. The interrupt is still thrown after every two scans regardless of the triggering event(s). While the first and second scan are saved to the selected ADC data register and the ADC duplexing register as before, scans associated with event A and B are additionally copied into duplexing register A and B, respectively (ADC_CHANNEL_DUPLEX_A and ADC_CHANNEL_DUPLEX_B).
This is a basic example of minimal use of the ADC in an application.
This example demonstrates reading data from a double-trigger scan. A flag is used to wait for a callback event. Two scans must occur before the callback is called. These results are read via R_ADC_E_Read using the selected channel enum value as well as ADC_CHANNEL_DUPLEX.
This example shows how to configure the window compare function at runtime as well as how to handle events and obtain comparison results through a callback.
{
(
adc_e_compare_cfg_t) (ADC_E_COMPARE_CFG_A_ENABLE | ADC_E_COMPARE_CFG_B_ENABLE | ADC_E_COMPARE_CFG_WINDOW_ENABLE),
.compare_ref_low = ADC_SCAN_MAX / 3,
.compare_ref_high = ADC_SCAN_MAX * 2 / 3,
.compare_b_channel = ADC_E_WINDOW_B_CHANNEL_2,
.compare_b_mode = ADC_E_WINDOW_B_MODE_GREATER_THAN_OR_INSIDE,
.compare_b_ref_low = ADC_SCAN_MAX / 4,
.compare_b_ref_high = ADC_SCAN_MAX * 3 / 4,
};
{
{
}
{
}
else
{
}
}
void adc_e_window_compare_example (void)
{
assert(FSP_SUCCESS == err);
g_adc0_channel_runtime_cfg.p_window_cfg = &g_adc0_window_cfg;
assert(FSP_SUCCESS == err);
while (1)
{
assert(FSP_SUCCESS == err);
}
}