主要内容

Analog to Digital Converter (r_adc)

R2026b

Convert analog signal to digital value using r_adc ADC peripheral

Since R2026b

  • Analog to Digital Converter (r_adc) block

Libraries:
Embedded Coder Support Package for Renesas RA Microcontrollers / Renesas RA6 Based

Description

Use the Analog to Digital Converter (r_adc) block to convert analog signals to digital values using the r_adc ADC peripheral on Renesas RA microcontrollers. This block is available on the RA6M2, RA6M3, RA6T1, and RA6T3 device series. The block output is a 1-by-N row vector, where N is the number of conversions. The block measures the voltage of analog pins relative to the analog input reference voltage.

Note

Continuous scan mode is not supported. The block performs single-scan conversions only.

Examples

Ports

Input

expand all

Triggers the ADC input pin for conversion.

  • 1 - ADC start of conversion is triggered

  • 0 - ADC start of conversion is not triggered

Dependencies

To enable this port, set the Trigger mode parameter to Trigger only.

Data Types: Boolean

Output

expand all

The block outputs the digital values of selected analog channels converted from the ADC as a 1-by-N vector, where N is the number of conversions.

Dependencies

To enable this port, set the Trigger mode parameter to either Trigger and read or Read results only.

Data Types: uint16

The block outputs the FSP API status code. 0 indicates FSP_SUCCESS and a nonzero value indicates an error.

Dependencies

To enable this port, select the Output status parameter.

Data Types: int32

Parameters

expand all

Select the r_adc stack instance configured in the RA Smart Configurator project. This links the block to a specific ADC hardware instance. Click Get Stack Info to retrieve the Stack ID from the linked RA Smart Configurator project, or specify it manually in character array format.

Programmatic Use

Block Parameter: StackID

Select the scan group for ADC conversion. Valid values are Scan Group A, Scan Group B, 0 (equivalent to Scan Group A), and 1 (equivalent to Scan Group B).

Programmatic Use

Block Parameter: GroupId

Specify the number of sampling clock cycles for the ADC sample-and-hold phase. This value is set in the Configuration Parameters under the hardware board settings. A higher sample state count increases sampling time, which can improve accuracy for high-impedance sources.

Programmatic Use

Block Parameter: ADCSampleStateCount

Choose how conversion is handled for this block.

  • Trigger and read — Triggers ADC start of conversion at every sample time. The block output waits until the conversion is complete and emits the results. This option enables the output port Cnts.

  • Trigger only — Triggers start of ADC conversion of specified conversion group. Use another Analog to Digital Converter (r_adc) block with the Trigger mode parameter set to Read results only to read the conversion results.

  • Read results only — Reads converted data. Check the Output status port to determine data validity: 0 indicates a successful read; any nonzero value indicates an error.

Programmatic Use

Block Parameter: TriggerMode

Specify the number of channels assigned to the scan group. The block outputs results as a 1-by-N row vector, where N is the number of conversions. Set this value to match the number of channels configured for the scan group in the RA Smart Configurator (RASC) project.

Dependencies

This parameter is not visible when the Read Double Trigger Results parameter is selected.

Programmatic Use

Block Parameter: NumberOfConversions

When you select this parameter, the block reads results of the double trigger operation configured in the RA Smart Configurator. The output size is always [1 2] when double trigger is enabled.

Note

Double trigger mode is applicable to Scan Group A only. If you are also using Scan Group B (Group Scan mode), configure Scan Group B as a separate Analog to Digital Converter (r_adc) block without selecting the Read Double Trigger Results parameter. Scan Group B is not affected by the double trigger configuration.

Note

This parameter is visible regardless of the Group ID value, but selecting it when Group ID is set to Scan Group B or 1 will result in an error during build.

Programmatic Use

Block Parameter: ReadDoubleTriggerResults

Select the type of result registers to read when double trigger is enabled in the RA Smart Configurator.

  • Standard — Reads the standard data registers (Data A and Data B) for the double trigger conversion results.

  • Extended — Reads the extended data registers, which include additional conversion metadata configured in RASC.

Dependencies

To enable this parameter, select the Read Double Trigger Results parameter.

Programmatic Use

Block Parameter: DoubleTriggerResultType

When you select this parameter, the block configures the Status output port. The Status port outputs the FSP API status code of the ADC operation. 0 indicates FSP_SUCCESS and a nonzero value indicates an error code.

Programmatic Use

Block Parameter: OutputStatus

Specify how often (in seconds) the block reads the pin value. Enter a value greater than zero. When you specify this parameter as -1, Simulink® determines the best sample time for the block based on the block context within the model.

Dependencies

To enable the Sample time parameter, set the Trigger mode parameter to either Trigger and read or Read results only.

Programmatic Use

Block Parameter: SampleTime

Version History

Introduced in R2026b