Renesas RX Family APPLICATION NOTE

APPLICATION NOTE
RX Family
RX Family MPC Module Using Firm ware Integration Technology Application Note
Introduction
This applicati on note describes the Multi-Functi on Pi n Controller (MPC) module which uses Firm ware Integration Technology (FIT). This module uses MPC to control the routing of a function to a pin. In this document, this module is referred to as the MPC FIT module.
Target Devices
RX110, RX111, RX113 Groups
RX130 Group
RX13T Group
RX230 Group
RX231 Group
RX23T Group
RX23W Group
RX23E-A Group
RX24T Group
RX24U Group
RX64M Group
RX651, RX65N Groups
RX66T Group
RX66N Group
RX71M Group
RX72T Group
RX72M Group
RX72N Group
When using this appli c ation note with other Renesas MCUs, caref ul ev aluation is recommended after m aki ng modificati ons to c om ply with t he alternate MCU.
Target Compilers
Renesas Electronics C/C++ Compiler Package for RX Family
GCC for Renesas RX
IAR C/C++ Compiler for Renesas RX
For details of the confirmed operation contents of each compiler, refer to “6.1 Confirmed Operation Environment".
R01AN1724EJ0380 Rev.3.80 Page 1 of 25 Apr.01.2021
RX Family MPC Mod ule Using Firmware Integration Technology Contents
1. Overview ................................................................................................................................. 4
1.1 MPC FIT Module ................................................................................................................................ 4
1.2 Overview of the MPC FIT Modul e ....................................................................................................... 4
1.3 API Overview ..................................................................................................................................... 4
2. API Information ........................................................................................................................ 5
2.1 Hardware Requirements .................................................................................................................... 5
2.2 Software Requirements ...................................................................................................................... 5
2.3 Limitations ......................................................................................................................................... 5
2.3.1 RAM Location Limitations ................................................................................................................. 5
2.4 Supported Tool c hain .......................................................................................................................... 5
2.5 Interrupt V ector .................................................................................................................................. 5
2.6 Header Files ...................................................................................................................................... 5
2.7 Integer Types ..................................................................................................................................... 5
2.8 Configuration Overview ...................................................................................................................... 6
2.9 Code Size .......................................................................................................................................... 6
2.10 Parameters ........................................................................................................................................ 6
2.10.1 MPC Pin Configuration ..................................................................................................................... 6
2.11 Return Values .................................................................................................................................... 7
2.12 Callback Function .............................................................................................................................. 7
2.13 Adding the FIT Module to Your Project ............................................................................................... 7
2.14 “for”, “while” and “do while” statem ents ............................................................................................... 8
3. API Function s .......................................................................................................................... 9
R_MPC_Write .............................................................................................................................................. 9
R_MPC_Read ........................................................................................................................................... 11
R_MPC_GetVersion .................................................................................................................................. 12
4. Pin Setting ............................................................................................................................. 13
5. Demo Projects ....................................................................................................................... 14
5.1 mpc_demo_rskrx113, mpc_demo_rskrx64m, mpc_demo_rskrx71m, mpc_demo_rskrx65n, mpc_demo_rskrx65n_2m, mpc_demo_rskrx113_gcc, mpc_demo_rskrx64m_gcc,
mpc_demo_rskrx71m_gcc, mpc_demo_rskrx65n_gcc, mpc_demo_rskrx65n_2m_gcc ..................... 14
5.2 mpc_demo_rskrx231, mpc_demo_rskrx231_gcc .............................................................................. 14
5.3 mpc_demo_rskrx72m, mpc_demo_rskrx72m_gcc ............................................................................ 14
5.4 Adding a Demo to a Workspace ....................................................................................................... 14
5.5 Downloading Demo Pr ojec ts ............................................................................................................ 14
6. Appendices ............................................................................................................................ 15
6.1 Confirmed Operation Environment ................................................................................................... 15
6.2 Troubleshooting ............................................................................................................................... 22
R01AN1724EJ0380 Rev.3.80 Page 2 of 25 Apr.01.2021
RX Family MPC Mod ule Using Firmware Integration Technology
7. Reference Documents ........................................................................................................... 23
Related Technical Updates ........................................................................................................... 23
Revision History ............................................................................................................................ 24
R01AN1724EJ0380 Rev.3.80 Page 3 of 25 Apr.01.2021
RX Family MPC Mod ule Using Firmware Integration Technology
Function
Description
R_MPC_Write()
Sets the function of a pin.
R_MPC_Read()
Reads the function c onfiguration of a pin.
R_MPC_GetVersion()
Returns the current v er si on of t his module.

1. Overview

1.1 MPC FIT Module

The MPC FIT module can be used by being im plem ented in a project as an API. See section 2.13, Adding the FIT Module to Your Project f or details on methods to implement this FIT module into a project.

1.2 Overview of the MPC FIT Module

Modern MCUs have continued to add more peripherals while still maintaining relatively low pin counts. When this occurs, each pin will have multiple functions allocated to it. On RX MCUs, the routing of a f unction to a pin is controlled by the Multi-Function Pin Controller. This driver abstracts this func tionality allowing use of the same pin definitions from the r_gpio_rx module.

1.3 API Overview

Table 1.1 lists the API functions included in this module.
Table 1.1 API Functi ons
R01AN1724EJ0380 Rev.3.80 Page 4 of 25 Apr.01.2021
RX Family MPC Mod ule Using Firmware Integration Technology

2. API Informa ti o n

This FIT module has been confirmed to operate under the following conditions.

2.1 Hardware Requirements

The MCU used must support the following functions:
MPC

2.2 Software Requirements

This driver is dependent upon the following FIT modules:
Renesas Board Support Package (r_bsp) v5.20 or higher  General Purpose Input/Out put Driver (r_gpio_rx)

2.3 Limitations

2.3.1 RAM Location Limitations

In FIT, if a value equivalent to NULL is set as the pointer argument of an API function, error might be returned due to parameter check. Therefore, do not pass a NULL equivalent value as pointer argument to an API function. The NULL value is defined as 0 because of the library function specifications. Theref or e, the above phenomenon would occur when the variable or functi on passed to the API function pointer argum ent is located at the start addres s of RA M (address 0x0). In this case, change the section settings or prepare a dummy variable at t he top of the RAM so that the vari able or function passed to the API function pointer argument is not located at address 0x0. In the case of the CCRX project (e2 studio V7.5.0), the RAM start addr ess is set as 0x4 t o pr ev ent the variable from bei ng loc ated at address 0x0. In the case of the GCC project (e2 studio V7.5.0) and IAR project (EWRX V4. 12.1), the start address of RAM is 0x0, so the abov e measures are necessary. The default settings of the section may be changed due to the IDE version upgrade. P lease check the section setti ngs when using t he latest IDE.

2.4 Supported Toolch ai n

This driver has been confirmed to work with the toolc hain listed in 6.1, Confirmed Operati on E nv ir onm ent.

2.5 Interrupt Vector

None.

2.6 Header Files

All API calls and thei r supporting interface defi nitions are located in “r_mpc_rx_if.h”.

2.7 Integer Types

This project uses ANSI C99. These types are def ined in stdint. h.
R01AN1724EJ0380 Rev.3.80 Page 5 of 25 Apr.01.2021
RX Family MPC Mod ule Using Firmware Integration Technology
Config ur a tion opti ons in r_ m pc _ r x _ c onfig.h
= 1: Include parameter checking in the buil d.
checking from the build.
ROM, RAM and Stack Code Sizes
Renesas Compiler
GCC
IAR
With
Checking
Without
Checking
With
Checking
Without
Checking
With
Checking
Without
Checking
Maximum usage

2.8 Configuration Overview

The configuration option settings of this module are located in r_mpc_rx_config.h. The option names and setting val ues are listed in the table below:
= 0: Omit parameter checking from the buil d.
MPC_CFG_PARAM_CHECK ING_ENABLE 1
= BSP_CFG_PARAM_CHECKING_ENABLE: Use the system default setting. Note: Code size can be reduc ed by excluding parameter

2.9 Code Size

Typical code sizes associated with this module are listed below. The ROM (code and constants) and RAM ( global data) sizes are determined by the build-time configuration
options described i n 2.8, Configuration Overview. The table lists ref er enc e v alues when the C c om piler’s compile options are set to their default values, as described in 2.4, Support ed Toolchain. The compile option default values are opt im iz ation level: 2, optimizati on type: for size, and data endianness: little-endian. The code size varies dependi ng on the C compiler version and compile options.
Memory Used
Device Category
All devices
Parameter
ROM 125 bytes 107 bytes 312 bytes 280 bytes 431 bytes 399 bytes
RAM 0 bytes 0 bytes 0 bytes 0 bytes 0 bytes 0 bytes
stack
52 bytes 52 bytes - - 52 bytes 52 bytes
Parameter
Parameter
Parameter
Parameter
Parameter

2.10 Parameters

This section describes the parameter struc ture used by the API functions in this module. T he str uc ture is located in r_mpc _rx_if.h as are the prototype declarations of API functions.

2.10.1 MPC Pin Configuration

This data struct ur e is used f or confi gur ing a pin’s function. To find vali d settings for pin_function, ref er to t he Multi-Function Pin Controller (MPC) section of your MCU’s hardware manual . Select the Pin Function Control Register for the port that y our pi n is on. On thi s page you will fi nd a table with available functi ons for each pin on the selected port .
/* Options for configuring the MPC register of a pin. */ typedef struct { uint8_t pin_function; //Which peripheral function is assigned to this pin bool irq_enable; //This pin is used as IRQ pin
R01AN1724EJ0380 Rev.3.80 Page 6 of 25 Apr.01.2021
RX Family MPC Mod ule Using Firmware Integration Technology
bool analog_enable; //This pin is used as ADC input, DAC output, or for //LVD (CMPA2) } mpc_config_t;

2.11 Return Values

This section describes return values of API functions. This enumerati on is l oc ated in r_mpc_rx_if.h as are the prototype declarations of API functions.
Below are the available return values for the R_MPC_Write( ) function.
/* Function return type. */ typedef enum { MPC_SUCCESS = 0, MPC_ERR_INVALID_CFG, // The configuration specified cannot be applied to // this pin } mpc_err_t;

2.12 Callback Function

None.

2.13 Adding the F IT Module to Your Project

This module must be added to each pr ojec t in which it is used. Renesas recommends the method usi ng the Smart Configurator described in (1) or (3) below. However, the Smart Configurator only support s some RX devices. Please use the methods of (2) or (4) for RX devices that ar e not supported by the Smart Configurator.
2
(1) Adding the FIT module to your project using the Smart Configur ator in e
By using the Smart Confi gur ator in e
Refer to “Renesas e
2
studio Sm art Configurator User Guide (R20A N0451) ” for details.
2
studio, the FIT module i s autom atically added to your project.
(2) Adding the FIT module to your project using the FIT Confi gur ator in e
By using the FIT Configurator in e
2
studio, the FIT module is automatically added to your project.
Refer to “Adding Fi rmware Integration Technol ogy Modules to Projects (R01AN1723)” for details.
(3) Adding the FIT module to your project using the Smart Configurator in CS+
By using the Smart Confi gur ator Standalone version in CS+ , t he FIT m odule is automatically added
to your project. Ref er to “Renesas e
2
studio Sm art Configurator User Guide (R20AN0451) ” for
details.
(4) Adding the FIT module to your project in CS+
In CS+, please manually add the FIT module to your project. Refer to “Adding Firmware Integration
Technology Modules to CS + P r ojec ts (R01AN1826)” for details.
studio
2
studio
R01AN1724EJ0380 Rev.3.80 Page 7 of 25 Apr.01.2021
RX Family MPC Mod ule Using Firmware Integration Technology

2.14 “for”, “while” and “do while” statements

In this module, “for ”, “ while” and “do while” statem ents (l oop pr oc essing) ar e used i n pr oc es si ng to wait for register to be reflected and so on. For these loop processing, comments with “WAIT_LOOP” as a keyword are described. Ther efore, if user incorpor ates fail-safe processing int o loop pr oc essing, user can search the corresponding proce ssing with “WAIT_LOOP” .
The following shows example of description.
while statement example : /* WAIT_LOOP */ while(0 == SYSTEM.OSCOVFSR.BIT.PLOVF) { /* The delay period needed is to make sure that the PLL has stabilized. */ }
for statement example : /* Initialize reference counters to 0. */ /* WAIT_LOOP */ for (i = 0; i < B SP_R EG_PROT ECT _T OT AL_ITEM S; i++) { g_protect_counters[i] = 0; }
do while statement ex am ple : /* Reset completion waiting */ do { reg = phy_ read(et her_ch an n el, PHY_REG _C O N T R O L); count++; } while ((reg & PHY_CONTROL_RESET) && (count < ETHER_CFG_PHY_DELAY_RESET)); /* WAIT_LOOP */
R01AN1724EJ0380 Rev.3.80 Page 8 of 25 Apr.01.2021
RX Family MPC Mod ule Using Firmware Integration Technology

3. API Functions

R_MPC_Write
This function sets the function of a pin.
Format
mpc_err_t R_MPC_Write (
gpio_port_pin_t pin, mpc_config_t * pconfig
)
Parameters
gpio_port_pin_t pin
Whic h pi n to configure.
mpc_config_t *pconfig
Pointer to structure with pin configuration information. See section 2.10.1, MPC Pin Configuration.
Return Values
[MPC_SUCCESS] /* Successful; pin configured. */ [MPC_ERR_INVALID_CFG] /* Err or ; invalid c onfiguration input */
Properties
Prototyped in file “r_mpc_rx_if.h”
Description
This function will c onfigure a pin based on the information in the mpc _c onfig_t structure. Not all pins support the same functionality . F or example, not all pins are able to be configured as anal og pins for ADC or DAC use. Also, not all combinations of functionali ty are capable. For example, a pin cannot be configured as an analog pin and for peripheral use at the same time.
To see what functions are available for a pin, refer to the Mult i-Function Pin Controller (MPC) secti on of your MCU’s hardware manual. Select the Pin Function Control Register for the port that your pin is on. On this page you will find a table with available functions for each pi n on the selec ted port.
Which pin is to be configured by this function is defined using the gpio_port_pin_t type fr om the r _gpio_rx module.
Example
mpc_config_t config; gpio_port_pin_t pin;
/* Set PE0 to be used as analog pin for ADC. */ pin = GPIO_PORT_E_PIN_0;
config.analog_enable = true; config.irq_enable = false; config.pin_function = 0;
if (MPC_SUCCESS != R_MPC_Write(pin, &config)) {
R01AN1724EJ0380 Rev.3.80 Page 9 of 25 Apr.01.2021
Loading...
+ 18 hidden pages