Skip to main content

Creating/Importing a Project

This section describes how to create a project with VK-RA6E1 to explore various options in the Utilities plugins. The VK (Voice Kit) board comes with a microphone for data collection. Ideally, you need some sensor connected to various Renesas RA MCUs/Boards to collect data and test machine learning models.

The example project is for illustration purposes only. You can recreate the same steps with other boards/MCUs in the RA series. This user manual also comes with a fully set up example project that you can reference.

Create a New Project

  1. On the top navigation menu, click File > New.

  2. Go to File > New and select Renesas C/C++ Project, then Renesas RA.

  3. In the new project wizard window, select Renesas RA C/C++ Project and click Next.
    New C/C++ Project

  4. Specify a project name and click Next.

  5. Select the FSP version matching your BSP and FSP installation (e.g., 5.5.0) and set the Board to the one you are connecting. In the example below, we are using AIK-RA6M3. Verify that the Debugger is set to JLink ARM and click Next.
    Renesas RA C/C++ Project

  6. On the next window, leave Executable and No RTOS selected. Click Next.

  7. Once the new project is created, e² Studio will switch to a layout optimized for developing Renesas RA projects.

    • Select the Stacks tab at the bottom of the FSP Configuration pane.
      FSP Configuration
    1. Access the New Stack menu and select Connectivity > I2C Communication Device (rm_comms_i2c).
      Use the Properties tab to configure the following properties for this new module:

I2C Communication Device Properties

NameSlave AddressCallback
g_comms_i2c_device10x68rm_icm42670_comms_i2c_callback

Why rm_comms_i2c?

Middleware to implement the I2C communications interface used by the sensor. This module implements the Communications Middleware Interface.

Features:

  • Reading and writing data over I2C bus
  • Writes to I2C bus, then reads with restart
  • Single I2C bus used by multiple devices

Configurations

Build Time Configurations for rm_comms_i2c
The following build time configurations are defined in fsp_cfg/rm_comms_i2c_cfg.h.

Build Time Configurations for rm_comms_i2c

ConfigurationOptionsDefaultDescription
Parameter CheckingDefault (BSP) / Enabled / DisabledDefault (BSP)If selected, code for parameter checking is included in the build.

Configurations for Connectivity > I2C Shared Bus (rm_comms_i2c)

This module can be added via New Stack > Connectivity > I2C Shared Bus (rm_comms_i2c).

Configurations for I2C Shared Bus (rm_comms_i2c)

ConfigurationOptionsDefaultDescription
NameName must be a valid C symbolg_comms_i2c_bus0Module name.
Bus TimeoutNon-negative integer ≤ 0xFFFFFFFF0xFFFFFFFFSet timeout for locking bus in RTOS.
Semaphore for Blocking (RTOS only)Unuse / UseUseSet semaphore for blocking in RTOS.
Recursive Mutex for Bus (RTOS only)Unuse / UseUseSet mutex for locking bus in RTOS.
ChannelManual Entry0IIC channel
RateStandard / Fast-mode / Fast-mode plusStandardTransfer rate for lower-level driver.

Configurations for Connectivity > I2C Communication Device (rm_comms_i2c)

This module can be added via New Stack > Connectivity > I2C Communication Device (rm_comms_i2c).

Configurations for I2C Communication Device (rm_comms_i2c)

ConfigurationOptionsDefaultDescription
NameValid C symbolg_comms_i2c_device0Module name.
Semaphore Timeout (RTOS only)Integer ≤ 0xFFFFFFFF0xFFFFFFFFSet timeout for blocking in RTOS.
Slave AddressNon-negative integer0x00Specify the slave address.
Address Mode7-Bit / 10-Bit7-BitSelect the I2C address mode.
CallbackValid C symbolcomms_i2c_callbackUser callback function.

Pin Configuration:
This module uses SDA and SCL pins of I2C Master, SCI I2C, IICA Master, and SAU I2C.


  1. In the I2C Communication Device module, in g_comms_i2c_bus1 I2C Shared Bus (rm_comms_i2c), use the Properties tab to configure the following:

Properties for g_comms_i2c_bus1

NameValue
Nameg_comms_i2c_bus1
Channel1
RateFast-mode

I2C Communication Device

  1. Add I2C Communications Peripherals

In the I2C Communication Device module, click the stack icon to Add I2C Communications peripherals, then click New and choose I2C Master (r_iic_master).

Use the Properties tab to configure the following properties for this new module.

I2C Master Properties

PropertyValue
Common > DTC on Transmission and ReceptionEnabled
Nameg_i2c_master1
Interrupt priority12
Timeout ModeShort Mode
  1. Add DTC Driver for Transmission (Optional)

In the I2C Communication Device module, click the stack icon for Add DTC Driver for Transmission [optional], then click New and choose Transfer (r_dtc).

  1. Access the New Stack menu again and select: Input > External IRQ (r_icu).

Use the Properties tab to configure the following properties for this new module.

External IRQ Properties

PropertyValue
Nameg_external_irq6_pmod1
Channel6
TriggerRising
Pin Interrupt PriorityPriority 12

Note: You should see pin IRQ06 update to P000 when you change Channel to 6.

Access the New Stack menu again and select Add AI > Data Shipper (rm_rai_data_shipper)

Why rm_rai_data_shipper?

This is the middleware to implement the Data Shipper for Reality AI applications.
This module implements the Data Shipper Interface.

Overview

RAI Data Shipper is mainly for sending data collected by RAI Data Collector to a PC so that it can be used for Reality AI model training.
It utilizes the Communications Middleware Interface and all communications are fully asynchronous.

The data being transported may be any combination of the following:

  • Sensor data
  • System events/errors
  • Debug data and diagnostic information (including RAI runtime output)

Sensor data is provided by a Data Collector instance via the data ready callback.
System events and debug data are prepared by the application.
A callback is used to notify the application when communication is finished.
Sensor data buffers must be released if they are not used.
An error flag will be set if there is any error during data transmission.

Features

  1. Supports up to 8 Data Collector instances.
  2. Supports the following interfaces:
    • RM_COMMS_UART with/without CRC-8
    • RM_COMMS_USB_PCDC with/without CRC-8

Configurations

Defined in fsp_cfg/rm_rai_data_shipper_cfg.h.

Build Time Configurations for rm_rai_data_shipper

ConfigurationOptionsDefaultDescription
Parameter CheckingDefault (BSP) | Enabled | DisabledDefault (BSP)If selected, code for parameter checking is included in the build.
Max Number Of DC InstancesPositive integer (1–8)8Maximum number of DC instances to send.

Configurations for AI > Data Shipper (rm_rai_data_shipper)

This module can be added to the Stacks tab via: New Stack > AI > Data Shipper (rm_rai_data_shipper).

Configurations for AI > Data Shipper

ConfigurationOptionsDefaultDescription
NameValid C symbolg_rai_data_shipper0Module name
Frame Rate DividerNon-negative value0Skip write requests
CallbackValid C symbolrai_data_shipper0_callbackUser callback function on data sent or error

Clock Configuration

This module has no required clock configurations.

Pin Configuration

This module does not use I/O pins.

Limitations

  1. Two-way communication is not supported — data is always sent from device to host.
  2. Users must avoid race conditions when using multiple data collector instances.
  3. To use RM_COMMS_USB_PCDC with Full Speed mode and DMA, frame buffer length must be a multiple of 2 when an 8-bit channel is used.
  4. To use RM_COMMS_USB_PCDC with High Speed mode and DMA:
    • Frame buffer length must be a multiple of 2 for 16-bit channel.
    • For 8-bit channel, frame buffer length must be a multiple of 4.
  5. RAI Data Collector (snapshot mode) and RM_COMMS_USB_PCDC must use different timers — they operate independently.

  1. Access g_rai_data_collector0

Use the Properties tab to configure the following properties for this new module.

Data Collector (g_rai_data_collector0) Properties

PropertyValue
General > Frame Buffer Length512
Data Feed Mode > Channels3
Data Feed Mode > Channels 0–2Set Channels 0, 1, and 2 Data Type to Single Float

Why g_rai_data_collector?

Middleware to implement the Data Collector for Reality AI applications. This module implements the Data Collector Interface.

Overview

Data Collector abstracts the collection of data from sensors so that data samples are accumulated into fixed-length frames before being made available to the application. Support of snapshot mode and data feed mode are required to accommodate background and cooperative data collection. Each mode supports up to 8 sensor channels. Each sensor channel will be captured into a separate frame buffer. Frame buffers shall have the same amount of data samples, however, data type can be different (int32_t, float, uint8_t, etc.). Users must ensure frame buffers will be filled at the same rate.

When all frame buffers are filled, they will be provided to the application via data ready callback. After they are consumed, the application must release them by calling RM_RAI_DATA_COLLECTOR_BufferRelease(). For seamless operation, PING-PONG buffers will be used. Ideally, buffers are released before the other set of buffers are filled. However, frame buffer overrun can occur if the application takes longer to process the data. If it happens, the application is notified with a buffer-overrun event via the error callback. No user intervention is required; buffer overrun will disappear when frame buffers are released. If not all sensor channels are configured to work at the same pace, the application will get a buffer-out-of-sync error. Users must reconfigure sensor channels and ensure all channels work at the same pace. If sensor channels can't work at the same rate, multiple data collector instances are required.

Features

  • Snapshot mode and data feed mode are supported.
  • Maximally 8 sensors are supported for each mode.
  • Mix mode is supported (both snapshot and data feed enabled).

Snapshot Mode

Snapshot mode periodically pulls data from user-specified sources and saves to designated frame buffers. It requires a DTC module and a timer module. DTC will work in chain mode, enabling data collection from various, potentially non-linear and different-sized sources. Timer (GPT or Asynchronous General Purpose Timer) provides activation source for DTC to work periodically. To select this activation source, relevant interrupt must be configured in the timer module. The application must start the timer to enable DTC after sensor source addresses are registered.

Data Feed Mode

Data feed mode requires the data producer to push data directly to the designated frame buffer whenever data is ready. Data can be pushed synchronously or asynchronously.

  • Synchronous mode: for short data copies to the frame buffer.
  • Asynchronous mode: uses DTC/DMAC for data transfer. Application must add DTC/DMAC modules and initialize transfer descriptors for asynchronous transfer.

Usage Notes

  1. Do not add DTC stack and timer stack to data collector instance for data feed mode.
  2. Users must make sure all channels of a data collector instance operate at the same pace.
  3. Interrupt priority level of the timer stack in the data collector instance must be higher (numerically lower) than that of RM COMMS USB PCDC GPT Overflow interrupt.

Configurations

Defined in fsp_cfg/rm_rai_data_collector_cfg.h.

Build Time Configurations for rm_rai_data_collector

ConfigurationOptionsDefaultDescription
Parameter CheckingDefault (BSP) / Enabled / DisabledDefault (BSP)If selected, code for parameter checking is included in the build.
Max Number Of ChannelsPositive integer ≤ 1616Max number of channels.

Configurations for AI > Data Collector (rm_rai_data_collector)

Add via New Stack > AI > Data Collector (rm_rai_data_collector).

Configurations for AI > Data Collector

CategorySetting / FieldOptions / ConstraintsDefault ValueDescription
GeneralNameName must be a valid C symbolg_rai_data_collector0Module name
GeneralIDPositive integer0Instance ID
GeneralFrame Buffer LengthPositive integer > 0100Length of frame buffers in data samples
GeneralData Ready CallbackName must be a valid C symbolrai_data_collector0_callbackCallback function on data ready
GeneralError CallbackName must be a valid C symbolrai_data_collector0_error_callbackCallback function for error events
Data FeedChannel 0 NameValid C variable namedc0_data_feed_ch0Channel name
Data FeedChannel 0 Data TypeMCU-specific optionsChannel Data Type
Data FeedChannel 1 NameValid C variable namedc0_data_feed_ch1Channel name
Data FeedChannel 1 Data TypeMCU-specific optionsChannel Data Type
Data FeedChannel 2 NameValid C variable namedc0_data_feed_ch2Channel name
Data FeedChannel 2 Data TypeMCU-specific optionsChannel Data Type
Data FeedChannel 3 NameValid C variable namedc0_data_feed_ch3Channel name
Data FeedChannel 3 Data TypeMCU-specific optionsChannel Data Type
Data FeedChannel 4 NameValid C variable namedc0_data_feed_ch4Channel name
Data FeedChannel 4 Data TypeMCU-specific optionsChannel Data Type
Data FeedChannel 5 NameValid C variable namedc0_data_feed_ch5Channel name
Data FeedChannel 5 Data TypeMCU-specific optionsChannel Data Type
Data FeedChannel 6 NameValid C variable namedc0_data_feed_ch6Channel name
Data FeedChannel 6 Data TypeMCU-specific optionsChannel Data Type
Data FeedChannel 7 NameValid C variable namedc0_data_feed_ch7Channel name
Data FeedChannel 7 Data TypeMCU-specific optionsChannel Data Type
Data FeedChannels (count)Integer between 0 and 80Number of Data Feed Mode channels
SnapshotSnapshot Channel 0 NameValid C variable namedc0_snapshot_ch0Channel name
SnapshotSnapshot Channel 0 Data TypeMCU-specific optionsChannel Data Type
SnapshotSnapshot Channel 1 NameValid C variable namedc0_snapshot_ch1Channel name
SnapshotSnapshot Channel 1 Data TypeMCU-specific optionsChannel Data Type
SnapshotSnapshot Channel 2 NameValid C variable namedc0_snapshot_ch2Channel name
SnapshotSnapshot Channel 2 Data TypeMCU-specific optionsChannel Data Type
SnapshotSnapshot Channel 3 NameValid C variable namedc0_snapshot_ch3Channel name
SnapshotSnapshot Channel 3 Data TypeMCU-specific optionsChannel Data Type
SnapshotSnapshot Channel 4 NameValid C variable namedc0_snapshot_ch4Channel name
SnapshotSnapshot Channel 4 Data TypeMCU-specific optionsChannel Data Type
SnapshotSnapshot Channel 5 NameValid C variable namedc0_snapshot_ch5Channel name
SnapshotSnapshot Channel 5 Data TypeMCU-specific optionsChannel Data Type
SnapshotSnapshot Channel 6 NameValid C variable namedc0_snapshot_ch6Channel name
SnapshotSnapshot Channel 6 Data TypeMCU-specific optionsChannel Data Type
SnapshotSnapshot Channel 7 NameValid C variable namedc0_snapshot_ch7Channel name
SnapshotSnapshot Channel 7 Data TypeMCU-specific optionsChannel Data Type
SnapshotChannels (count)Integer between 0 and 80Number of snapshot mode channels
SnapshotDTC Transfer CountPositive integer > 01DTC transfer count on each activation
Clock ConfigThis module has no required clock configurations
Pin ConfigThis module does not use I/O pins

  1. Add COMMS Driver — USB PCDC (rm_comms_usb_pcdc)

Under the Data Shipper module:

  1. Click Add COMMS Driver.
  2. Click New → USB PCDC Communication Device (rm_comms_usb_pcdc).

Add COMMS Driver

Overview
Middleware to implement a generic communications interface over USB_PCDC. This module implements the Communications Middleware Interface.

Features

  • Non-blocking API for bare metal.
  • Non-blocking and blocking API for RTOS.

  1. Configure g_timer0 Timer (General PWM - r_gpt)

Timer g_timer0 Properties

PropertyValue
General > Period500
General > Period UnitMicroseconds
Interrupts > Overflow/Crest Interrupt PriorityPriority 12

Why r_gpt?

Driver for the GPT32 and GPT16 peripherals on RA MCUs. This module implements the Timer Interface.


Overview

The GPT module can be used to count events, measure external input signals, generate a periodic interrupt, or output a periodic or PWM signal to a GTIOC pin.

This module supports the GPT peripherals GPT32EH, GPT32E, GPT32, and GPT16.
GPT16 is a 16-bit timer. The other peripherals (GPT32EH, GPT32E, and GPT32) are 32-bit timers. The 32-bit timers are all treated the same in this module from the API perspective.


Features

  • Supports periodic mode, one-shot mode, and PWM mode.
  • Supports count source of PCLK, GTETRG pins, GTIOC pins, or ELC events.
  • Supports debounce filter on GTIOC pins.
  • Signal can be output to a pin.
  • Configurable period (counts per timer cycle).
  • Configurable duty cycle in PWM mode.
  • Supports runtime reconfiguration of period.
  • Supports runtime reconfiguration of duty cycle in PWM mode.
  • Supports runtime reconfiguration of compare match value.
  • APIs are provided to start, stop, and reset the counter.
  • APIs are provided to get the current period, source clock frequency, and count direction.
  • APIs are provided to get the current timer status and counter value.
  • Supports start, stop, clear, count up, count down, and capture by external sources from GTETRG pins, GTIOC pins, or ELC events.
  • Supports symmetric and asymmetric PWM waveform generation.
  • Supports one-shot synchronous pulse waveform generation.
  • Supports automatic addition of dead time.
  • Supports generating ELC events to start an ADC scan at a compare match value (see Event Link Controller (r_elc)) and updating the compare match value.
  • Supports linking with a POEG channel to automatically disable GPT output when an error condition is detected.
  • Supports setting the counter value while the timer is stopped.
  • Supports enabling and disabling output pins.
  • Supports skipping up to seven overflow/underflow (crest/trough) interrupts at a time.
  • Supports generating custom PWM waveforms by configuring the pin's output level at each compare match and cycle end.

  1. Configure r_usb_basic

r_usb_basic Properties

PropertyValue
Module > USBFS Interrupt PriorityPriority 10
Module > USBFS Resume PriorityPriority 10
Module > USBFS D0FIFO Interrupt PriorityPriority 10
Module > USBFS D1FIFO Interrupt PriorityPriority 10

  1. Configure g_timeout_timer2 Timer (General PWM - r_gpt)

Timer g_timeout_timer2 Properties

PropertyValue
General > Nameg_timeout_timer2
General > Channel2
General > ModeOne-Shot
General > Period250
General > Period UnitMillisecond
Interrupts > Callbackgpt_timeout_callback
Interrupts > Overflow/Crest Interrupt PriorityPriority 13

  1. Configure g_led_timer1 Timer (General PWM - r_gpt)

Timer g_led_timer1 Properties

PropertyValue
General > Nameg_led_timer1
General > Channel1
General > ModePeriodic
General > Period250
General > Period UnitMillisecond
Interrupts > Callbackrai_led_timer_callback
Interrupts > Overflow/Crest Interrupt PriorityPriority 15

  1. Apply RA Configuration

RA Configuration for this section is complete. Apply changes to the project source by clicking the Generate Project Content button in the top-right corner of the Configurator window.

When prompted to Proceed with save and generate, tick the box next to Always save and generate without asking and click Proceed.

Generate Project Content


  1. Generate Code

The FSP Configurator will extract all the necessary drivers and generate the code based on the configuration provided in the Properties tab.
Now, you can add the required Reality AI Model files and run the project to test models and collect data.


Import an Existing Project

Use this option to load an existing project (including the example project provided with this document).

  1. On the top navigation menu, click File > Import.

Import Project

  1. In the Import dialog box, select General > Existing Projects into Workspace.

Select Existing Projects into Workspace

  1. Click Select root directory, then click Browse to navigate to your project location.

Select root directory

  1. Select the required project and click Finish.