Renesas RX API User Manual

Smart Configurator
User's Manual: RX API Reference
Rev.1.05 Oct. 2020
Target Device RX Family
www.renesas.com
All information contained in these materials, including products and product specifications, represents information on the product at the time of publication and is subject to change by Renesas Electronics Corp. without notice. Please review the latest information published by Renesas Electronics Corp. through various means, including the Renesas Electronics Corp.
website (http://www.renesas.com).
How to Use This Manual
Readers The target readers of this manual are the application system engineers who use the
Code Generator and need to understand its function.
Purpose The purpose of this manual is to explain the user for understanding and using the
Code Generator functions. We aim to help their system development including their hardware and software.
Organization This manual can be broadly divided into the following units.
1.GENERAL
2.OUTPUT FILES
3.API FUNCITONS
How to Read This Manual It is assumed that the readers of this manual have general knowledge of electricity,
logic circuits, and microcontrollers.
Conventions Deata significance: Higher digits on the left and lower digits on the right Active low representation: XXX (overscore over pin or signal name) Note: Footnote for item marked with Note in the text Caution: Information requiring particular attention Remark: Supplementary information Numeric representation: Decimal ... XXXX Hexadecimal ... 0xXXXX
All trademarks and registered trademarks are the property of their respective owners.
TABLE OF CONTENTS
1. GENERAL...................................................................................................................................................... 6
1.1 Overview ............................................................................................................................................................ 6
1.2 Features ............................................................................................................................................................... 6
2. OUTPUT FILES ............................................................................................................................................. 7
2.1 Description .......................................................................................................................................................... 7
3. INITIALIZATION .......................................................................................................................................... 20
4. API FUNCTIONS ......................................................................................................................................... 21
4.1 Overview .......................................................................................................................................................... 21
4.2 Function Reference ........................................................................................................................................... 22
4.2.1 Common .................................................................................................................................................. 24
4.2.2 8-Bit timer ................................................................................................................................................ 34
4.2.3 Buses ........................................................................................................................................................ 42
4.2.4 Clock Frequency Accuracy Measurement Circuit ................................................................................... 50
4.2.5 Comparator .............................................................................................................................................. 59
4.2.6 Compare Match Timer ............................................................................................................................. 66
4.2.7 Complementary PWM Mode Timer ........................................................................................................ 76
4.2.8 Continuous Scan Mode S12AD ............................................................................................................... 86
4.2.9 CRC Calculator ...................................................................................................................................... 101
4.2.10 D/A Converter ....................................................................................................................................... 111
4.2.11 Data Operation Circuit ........................................................................................................................... 120
4.2.12 Data Transfer Controller ........................................................................................................................ 129
4.2.13 Dead Time Compensaion Counter ......................................................................................................... 135
4.2.14 DMA Controller ..................................................................................................................................... 142
4.2.15 Event Link Controller ............................................................................................................................ 156
4.2.16 General PWM Timer (GPT) .................................................................................................................. 166
4.2.17 Group Scan Mode S12AD ..................................................................................................................... 183
4.2.18 I2C Master Mode ................................................................................................................................... 200
4.2.19 I2C Slave Mode ..................................................................................................................................... 233
4.2.20 Interrupt Controller ................................................................................................................................ 249
4.2.21 Low Power Consumption ...................................................................................................................... 265
4.2.22 Low Power Timer .................................................................................................................................. 277
4.2.23 Normal Mode Timer .............................................................................................................................. 283
4.2.24 Phase Counting Mode Timer ................................................................................................................. 291
4.2.25 Port Output Enable................................................................................................................................. 300
4.2.26 I/O Port .................................................................................................................................................. 311
4.2.27 Programmable Pulse Generator ............................................................................................................. 315
4.2.28 PWM Mode Timer ................................................................................................................................. 319
4.2.29 Realtime Clock ...................................................................................................................................... 327
4.2.30 Remote Control Signal Receiver ........................................................................................................... 352
4.2.31 SCI/SCIF Asynchronous Mode ............................................................................................................. 368
4.2.32 SCI/SCIF Clock Synchronous Mode ..................................................................................................... 392
4.2.33 Single Scan Mode S12AD ..................................................................................................................... 415
4.2.34 Smart Card Interface Mode .................................................................................................................... 430
4.2.35 SPI Clock Synchronous Mode ................................ ................................................................ ............... 445
4.2.36 SPI Operation Mode .............................................................................................................................. 466
4.2.37 Voltage Detection Circuit ...................................................................................................................... 481
4.2.38 Watchdog Timer .................................................................................................................................... 488
4.2.39 Continuous Scan Mode DSAD .............................................................................................................. 496
4.2.40 Single Scan Mode DSAD ...................................................................................................................... 507
4.2.41 Delta-Sigma Modulator Interface .......................................................................................................... 518
4.2.42 Analog Front End .................................................................................................................................. 527
4.2.43 Motor ..................................................................................................................................................... 530
Revision Record ............................................................................................................................................... 543
Smart Configurator. 2.GENERAL
R20UT4360EJ0105 Rev.1.05 Page 6 of 533 Oct. 20, 2020
1.

GENERAL

This chapter gives an overview of the driver code generator (hereafter abbreviated as Code Generator)
of the Smart Configurator.

1.1 Overview

his tool can output source code (device driver programs as C source and header files) for controlling
peripheral modules (clock generation circuit, voltage detection circuit, etc.) of the device by using a GUI to
set various types of information on the requirements of the project.

1.2 Features

The features of the Code Generator are as follows.
- Generating code
The Code Generator outputs not only device driver files in accord with the information set in the GUI but also a complete set of programs for the build environment, such as a sample program containing
the call of the main function.
- Reporting
Information that was set by using the Code Generator can be output to files in various formats and
used as design documentation.
- Renaming
Default names are given to folders and files output by the Code Generator and to the API functions in
the source code, but these can be changed to user-specified names.
- Protecting user code
,The user can add user's original source code to each API function. When user generated the device
driver programs again by the Code Generator, user's source code within this comment is protected.
[Comment for user source code descriptions] /* Start user code. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */
Code written by the user between these comments will be preserved even when the code is generated again.

Smart Configurator. 2. OUTPUT FILES

R20UT4360EJ0105 Rev.1.05 Page 7 of 533 Oct. 20, 2020
2.
OUTPUT FILES
This chapter explains the file output by the Code Generator.

2.1 Description

The Code Generator outputs the following files.
Table 2.1 Output File List (1/13)
Peripheral Function
File Name
API Function Name
Common
<workspaceName>.c
main
dbsct.c
resetprg.c
PowerON_Reset
sbrk.c
vecttbl.c
vecttbl.h
hwsetup.c
hardware_setup
hwsetup.h
r_cg_hardware_setup.c
r_undefined_exception R_Systeminit
r_cg_macrodriver.h
r_cg_userdefine.h
r_smc_entry.h
r_smc_cgc.c
R_CGC_Create
r_smc_cgc_user.c
R_CGC_Create_UserInit
r_smc_cgc.h
r_smc_interrup.c
R_Interrupt_Create
r_smc_interrupt.h
Pin.c
R_Pins_Create
Pin.h
Smart Configurator. 2. OUTPUT FILES
R20UT4360EJ0105 Rev.1.05 Page 8 of 533 Oct. 20, 2020
Table 2.2 Output File List (2/13)
Peripheral Function
File Name
API Function Name
8-Bit timer
<Config_TMR0>.c
R_<Config_TMR0>_Create R_<Config_TMR0>_Start R_<Config_TMR0>_Stop
<Config_TMR0>_user.c
R_<Config_TMR0>_Create_UserInit r_<Config_TMR0>_cmimn_interrupt r_<Config_TMR0>_ovin_interrupt
<Config_TMR0>.h
Buses
<Config_BSC>.c
R_<Config_BSC>_Create R_<Config_BSC>_Error_Monitoring_Start R_<Config_BSC>_Error_Monitoring_Stop R_<Config_BSC>_InitializeSDRAM
<Config_BSC>_user.c
R_<Config_BSC>_Create_UserInit r_<Config_BSC>_buserr_interrupt
<Config_BSC>.h
Clock Frequency
Accuracy Measurement
Circuit
<Config_CAC>.c
R_<Config_CAC>_Create R_<Config_CAC>_Start R_<Config_CAC>_Stop
<Config_CAC>_user.c
R_<Config_CAC>_Create_UserInit r_<Config_CAC>_mendf_interrupt r_<Config_CAC>_mendi_interrupt r_<Config_CAC>_ferrf_interrupt r_<Config_CAC>_ferri_interrupt r_<Config_CAC>_ovff_interrupt r_<Config_CAC>_ovfi_interrupt
<Config_CAC>.h
Comparator
<Config_CMPB0>.c
R_<Config_CMPB0>_Create R_<Config_CMPB0>_Start R_<Config_CMPB0>_Stop
<Config_CMPB0>user.c
R_<Config_CMPB0>_Create_UserInit r_<Config_CMPB0>_cmpbn_interrupt
<Config_CMPB0>.h
Compare Match Timer
<Config_CMT0>.c
R_<Config_CMT0>_Create R_<Config_CMT0>_Start R_<Config_CMT0>_Stop
<Config_CMT0>_user.c
R_<Config_CMT0>_Create_UserInit r_<Config_CMT0>_cmin_interrupt r_<Config_CMT0>_cmwin_interrupt r_<Config_CMT0>_icmin_interrupt r_<Config_CMT0>_ocmin_interrupt
<Config_CMT0>.h
Smart Configurator. 2. OUTPUT FILES
R20UT4360EJ0105 Rev.1.05 Page 9 of 533 Oct. 20, 2020
Table 2.3 Output File List (3/13)
Peripheral Function
File Name
API Function Name
Complementary PWM Mode Timer
<Config_MTU3_MTU4>.c
R_<Config_MTU3_MTU4>_Create R_<Config_MTU3_MTU4>_Start R_<Config_MTU3_MTU4>_Stop
<Config_MTU3_MTU4>_user.c
R_<Config_MTU3_MTU4>_Create_UserInit r_<Config_MTU3_MTU4>_tgimn_interrupt r_<Config_MTU3_MTU4>_cj_tgimj_interrupt r_<Config_MTU3_MTU4>_cj_tcivj_interrupt
<Config_MTU3_MTU4>.h
Continuous Scan Mode
S12AD
<Config_S12AD0>.c
R_<Config_S12AD0>_Create R_<Config_S12AD0>_Start R_<Config_S12AD0>_Stop R_<Config_S12AD0>_Get_ValueResult R_<Config_S12AD0>_Set_CompareValue R_<Config_S12AD0>_Set_CompareAValue R_<Config_S12AD0>_Set_CompareBValue
<Config_S12AD0>_user.c
R_<Config_S12AD0>_Create_UserInit r_<Config_S12AD0>_interrupt r_<Config_S12AD0>_compare_interrupt r_<Config_S12AD0>_compare_interruptA r_<Config_S12AD0>_compare_interruptB
<Config_S12AD0>.h
CRC Calculator
<Config_CRC>.c
R_<Config_CRC>_SetCRC8 R_<Config_CRC>_SetCRC16 R_<Config_CRC>_SetCCITT R_<Config_CRC>_SetCRC32 R_<Config_CRC>_SetCRC32C R_<Config_CRC>_Input_Data R_<Config_CRC>_Get_Result
<Config_CRC.h
D/A Converter
<Config_DA>.c
R_<Config_DA>_Create R_<Config_DA>n_Start R_<Config_DA>n_Stop R_<Config_DA>n_Set_ConversionValue R_<Config_DA>_Sync_Start R_<Config_DA>_Sync_Stop
<Config_DA>_user.c
R_<Config_DA>_Create_UserInit
<Config_DA>.h
Smart Configurator. 2. OUTPUT FILES
R20UT4360EJ0105 Rev.1.05 Page 10 of 533 Oct. 20, 2020
Table 2.4 Output File List (4/13)
Peripheral Function
File Name
API Function Name
Data Operation Circuit
<Config_DOC>.c
R_<Config_DOC>_Create R_<Config_DOC>_SetMode R_<Config_DOC>_WriteData R_<Config_DOC>_GetResult R_<Config_DOC>_ClearFlag
<Config_DOC>_user.c
R_<Config_DOC>_Create_UserInit r_<Config_DOC>_dopcf_interrupt r_<Config_DOC>_dopci_interrupt
<Config_DOC>.h
Data Transfer Controller
<Config_DTC>.c
R_<Config_DTC>_Create R_<Config_DTC>_Start R_<Config_DTC>_Stop
<Config_DTC>_user.c
R_<Config_DTC>_Create_UserInit
<Config_DTC>.h
Dead Time Compensaion Counter
<Config_MTU5>.c
R_<Config_MTU5>_Create R_<Config_MTU5>_Start R_<Config_MTU5>_Stop
<Config_MTU5>_user.c
R_<Config_MTU5>_Create_UserInit r_<Config_MTU5>_tgimn_interrupt
<Config_MTU5>.h
DMA Controller
<Config_DMAC0>.c
R_<Config_DMAC0>_Create R_<Config_DMAC0>_Start R_<Config_DMAC0>_Stop R_<Config_DMAC0>_Set_SoftwareTrigger R_<Config_DMAC0>_Clear_SoftwareTrigger
<Config_DMAC0>_user.c
R_<Config_DMAC0>_Create_UserInit r_<Config_DMAC0>_dmacni_interrupt r_dmacn_callback_transfer_end r_dmacn_callback_transfer_escape_end
<Config_DMAC0>.h
r_cg_dmac_user.c
r_dmac_dmac74i_interrupt r_dmacn_callback_transfer_end r_dmacn_callback_transfer_escape_end
r_cg_dmac.h
Event Link Controller
<Config_ELC>.c
R_<Config_ELC>_Create R_<Config_ELC>_Start R_<Config_ELC>_Stop R_<Config_ELC>_GenerateSoftwareEvent R_<Config_ELC>_Set_PortBuffern R_<Config_ELC>_Get_PortBuffern
<Config_ELC>_user.c
R_<Config_ELC>_Create_UserInit r_<Config_ELC>_elsrni_interrupt
<Config_ELC>.h
Smart Configurator. 2. OUTPUT FILES
R20UT4360EJ0105 Rev.1.05 Page 11 of 533 Oct. 20, 2020
Table 2.5 Output File List (5/13)
Peripheral Function
File Name
API Function Name
General PWM Timer
<Config_GPT0>.c
R_<Config_GPT0>_Create R_<Config_GPT0>_Start R_<Config_GPT0>_Stop R_<Config_GPT0>_HardwareStart R_<Config_GPT0>_HardwareStop R_<Config_GPT0>_ETGI_Start R_<Config_GPT0>_ETGI_Stop R_<Config_GPT0>_Software_Clear
<Config_GPT0>_user.c
R_<Config_GPT0>_Create_UserInit r_<Config_GPT0>_gtcimn_interrupt r_<Config_GPT0>_gtcivn_interrupt r_<Config_GPT0>_gtcinn_interrupt r_<Config_GPT0>_gdten_interrupt
<Config_GPT0>.h
r_cg_gpt_user.c
r_gpt_etgin_interrupt r_gpt_etgip_interrupt
r_cg_gpt.h
Group Scan Mode S12AD
<Config_S12AD0>.c
R_<Config_S12AD0>_Create R_<Config_S12AD0>_Start R_<Config_S12AD0>_Stop R_<Config_S12AD0>_Get_ValueResult R_<Config_S12AD0>_Set_CompareValue R_<Config_S12AD0>_Set_CompareAValue R_<Config_S12AD0>_Set_CompareBValue
<Config_S12AD0>_user.c
R_<Config_S12AD0>_Create_UserInit r_<Config_S12AD0>_interrupt r_<Config_S12AD0>_compare_interrupt r_<Config_S12AD0>_compare_interruptA r_<Config_S12AD0>_compare_interruptB r_<Config_S12AD0>_groupb_interrupt r_<Config_S12AD0>_groupc_interrupt
<Config_S12AD0>.h
Smart Configurator. 2. OUTPUT FILES
R20UT4360EJ0105 Rev.1.05 Page 12 of 533 Oct. 20, 2020
Table 2.6 Output File List (6/13)
Peripheral Function
File Name
API Function Name
I2C Master Mode
<Config_RIIC0>.c
R_<Config_RIIC0>_Create R_<Config_RIIC0>_Start R_<Config_RIIC0>_Stop R_<Config_RIIC0>_Master_Send R_<Config_RIIC0>_Master_Send_Without_Stop R_<Config_RIIC0>_Master_Receive R_<Config_RIIC0>_IIC_StartCondition R_<Config_RIIC0>_IIC_StopCondition
<Config_RIIC0>_user.c
R_<Config_RIIC0>_Create_UserInit r_<Config_RIIC0>_error_interrupt r_<Config_RIIC0>_receive_interrupt r_<Config_RIIC0>_transmit_interrupt r_<Config_RIIC0>_transmitend_interrupt r_<Config_RIIC0>_callback_receiveerror r_<Config_RIIC0>_callback_transmitend r_<Config_RIIC0>_callback_receiveend
<Config_RIIC0>.h
<Config_SCI0>.c
R_<Config_SCI0>_Create R_<Config_SCI0>_Start R_<Config_SCI0>_Stop R_<Config_SCI0>_IIC_Master_Send R_<Config_SCI0>_IIC_Master_Receive R_<Config_SCI0>_IIC_StartCondition R_<Config_SCI0>_IIC_StopCondition
<Config_SCI0>_user.c
R_<Config_SCI0>_Create_UserInit
r_<Config_SCI0>_receive_interrupt r_<Config_SCI0>_transmit_interrupt r_<Config_SCI0>_transmitend_interrupt r_<Config_SCI0>_callback_transmitend r_<Config_SCI0>_callback_receiveend
<Config_SCI0>.h
I2C Slave Mode
<Config_RIIC0>.c
R_<Config_RIIC0>_Create R_<Config_RIIC0>_Start R_<Config_RIIC0>_Stop R_<Config_RIIC0>_Slave_Send R_<Config_RIIC0>_Slave_Receive
<Config_RIIC0>_user.c
R_<Config_RIIC0>_Create_UserInit r_<Config_RIIC0>_error_interrupt r_<Config_RIIC0>_receive_interrupt r_<Config_RIIC0>_transmit_interrupt r_<Config_RIIC0>_transmitend_interrupt r_<Config_RIIC0>_callback_receiveerror r_<Config_RIIC0>_callback_transmitend r_<Config_RIIC0>_callback_receiveend
<Config_RIIC0>.h
Smart Configurator. 2. OUTPUT FILES
R20UT4360EJ0105 Rev.1.05 Page 13 of 533 Oct. 20, 2020
Table 2.7 Output File List (7/13)
Peripheral Function
File Name
API Function Name
Interrupt Controller
<Config_ICU>.c
R_<Config_ICU>_Create R_<Config_ICU>_IRQn_Start R_<Config_ICU>_IRQn_Stop R_<Config_ICU>_Software_Start R_<Config_ICU>_Software_Stop R_<Config_ICU>_SoftwareInterrupt_Generate R_<Config_ICU>_Software2_Start R_<Config_ICU>_Software2_Stop R_<Config_ICU>_SoftwareInterrupt2_Generate
<Config_ICU>_user.c
R_<Config_ICU>_Create_UserInit r_<Config_ICU>_irqn_interrupt r_<Config_ICU>_software_interrupt r_<Config_ICU>_software2_interrupt r_<Config_ICU>_nmi_interrupt
<Config_ICU>.h
Low Power Consumption
<Config_LPC>.c
R_<Config_LPC>_Create R_<Config_LPC>_AllModuleClockStop R_<Config_LPC>_Sleep R_<Config_LPC>_DeepSleep R_<Config_LPC>_SoftwareStandby R_<Config_LPC>_DeepSoftwareStandby R_<Config_LPC>_ChangeOperatingPowerControl R_<Config_LPC>_ChangeSleepModeReturnClock R_<Config_LPC>_SetVOLSR_PGAVLS
<Config_LPC>_user.c
R_<Config_LPC>_Create_UserInit
<Config_LPC>.h
Low Power Timer
<Config_LPT>.c
R_<Config_LPT>_Create R_<Config_LPT>_Start R_<Config_LPT>_Stop
<Config_LPT>_user.c
R_<Config_LPT>_Create_UserInit
<Config_LPT>.h
Normal Mode Timer
<Config_MTU0>.c
R_<Config_MTU0>_Create R_<Config_MTU0>_Start R_<Config_MTU0>_Stop
<Config_MTU0>_user.c
R_<Config_MTU0>_Create_UserInit r_<Config_MTU0>_tgimn_interrupt r_<Config_MTU0>_tginm_interrupt r_<Config_MTU0>_tcivn_interrupt r_<Config_MTU0>_tcinv_interrupt
<Config_MTU0>.h
Smart Configurator. 2. OUTPUT FILES
R20UT4360EJ0105 Rev.1.05 Page 14 of 533 Oct. 20, 2020
Table 2.8 Output File List (8/13)
Peripheral Function
File Name
API Function Name
Phase Counting Mode Timer
<Config_MTU1>.c
R_<Config_MTU1>_Create R_<Config_MTU1>_Start R_<Config_MTU1>_Stop
<Config_MTU1>_user.c
R_<Config_MTU1>_Create_UserInit r_<Config_MTU1>_tgimn_interrupt r_<Config_MTU1>_tginm_interrupt r_<Config_MTU1>_tcivn_interrupt r_<Config_MTU1>_tcinv_interrupt r_<Config_MTU1>_tciun_interrupt r_<Config_MTU1>_tcinu_interrupt
<Config_MTU1>.h
Port Output Enable
<Config_POE>.c
R_<Config_POE>_Create R_<Config_POE>_Start R_<Config_POE>_Stop R_<Config_POE>_Set_HiZ_MTUn R_<Config_POE>_Clear_HiZ_MTUn R_<Config_POE>_Set_HiZ_GPTn R_<Config_POE>_Clear_HiZ_GPTn
<Config_POE>_user.c
R_<Config_POE>_Create_UserInit r_<Config_POE>_oein_interrupt
<Config_POE>.h
I/O Port
<Config_PORT>.c
R_<Config_PORT>_Create
<Config_PORT>_user.c
R_<Config_PORT>_Create_UserInit
<Config_PORT>.h
Programmable Pulse Generator
<Config_PPG0>.c
R_<Config_PPG0>_Create
<Config_PPG0>_user.c
R_<Config_PPG0>_Create_UserInit
<Config_PPG0>.h
PWM Mode Timer
<Config_MTU0>.c
R_<Config_MTU0>_Create R_<Config_MTU0>_Start R_<Config_MTU0>_Stop
<Config_MTU0>_user.c
R_<Config_MTU0>_Create_UserInit r_<Config_MTU0>_tgimn_interrupt r_<Config_MTU0>_tginm_interrupt r_<Config_MTU0>_tcivn_interrupt r_<Config_MTU0>_tcinv_interrupt
<Config_MTU0>.h
Smart Configurator. 2. OUTPUT FILES
R20UT4360EJ0105 Rev.1.05 Page 15 of 533 Oct. 20, 2020
Table 2.9 Output File List (9/13)
Peripheral Function
File Name
API Function Name
Realtime Clock
<Config_RTC>.c
R_<Config_RTC>_Create R_<Config_RTC>_Start R_<Config_RTC>_Stop R_<Config_RTC>_Restart R_<Config_RTC>_Restart_BinaryCounter R_<Config_RTC>_Set_CalendarCounterValue R_<Config_RTC>_Get_CalendarCounterValue R_<Config_RTC>_Get_CalendarTimeCaptureValuen R_<Config_RTC>_Set_BinaryCounterValue R_<Config_RTC>_Get_BinaryCounterValue R_<Config_RTC>_Get_BinaryTimeCaptureValuen R_<Config_RTC>_Set_RTCOUTOn R_<Config_RTC>_Set_RTCOUTOff R_<Config_RTC>_Set_CalendarAlarm R_<Config_RTC>_Set_BinaryAlarm R_<Config_RTC>_Set_ConstPeriodInterruptOn R_<Config_RTC>_Set_ConstPeriodInterruptOff R_<Config_RTC>_Set_CarryInterruptOn R_<Config_RTC>_Set_CarryInterruptOff
<Config_RTC>_user.c
R_<Config_RTC>_Create_UserInit r_<Config_RTC>_alm_interrupt r_<Config_RTC>_prd_interrupt r_<Config_RTC>_cup_interrupt
<Config_RTC>.h
Remote Control Signal Receiver
<Config_REMC0>.c
R_<Config_REMC0>_Create R_<Config_REMC0>_Start R_<Config_REMC0>_Stop R_<Config_REMC0>_Read
<Config_REMC0>_user.c
R_<Config_REMC0>_Create_UserInit r_<Config_REMC0>_remcin_interrupt r_<Config_REMC0>_callback_comparematch r_<Config_REMC0>_callback_receiveerror r_<Config_REMC0>_callback_receiveend r_<Config_REMC0>_callback_bufferfull r_<Config_REMC0>_callback_header r_<Config_REMC0>_callback_data0 r_<Config_REMC0>_callback_data1 r_<Config_REMC0>_callback_specialdata
<Config_REMC0>.h
Smart Configurator. 2. OUTPUT FILES
R20UT4360EJ0105 Rev.1.05 Page 16 of 533 Oct. 20, 2020
Table 2.10 Output File List (10/13)
Peripheral Function
File Name
API Function Name
SCI/SCIF Asynchronous
Mode
<Config_SCI0>.c
R_<Config_SCI0>_Create R_<Config_SCI0>_Start R_<Config_SCI0>_Stop R_<Config_SCI0>_Serial_Send R_<Config_SCI0>_Serial_Receive R_<Config_SCI0>_Serial_Multiprocessor_Send R_<Config_SCI0>_Serial_Multiprocessor_Receive
<Config_SCI0>_user.c
R_<Config_SCI0>_Create_UserInit r_<Config_SCI0>_transmitend_interrupt r_<Config_SCI0>_transmit_interrupt r_<Config_SCI0>_receive_interrupt r_<Config_SCI0>_receiveerror_interrupt r_<Config_SCI0>_teif_interrupt r_<Config_SCI0>_txif_interrupt r_<Config_SCI0>_rxif_interrupt r_<Config_SCI0>_drif_interrupt r_<Config_SCI0>_erif_interrupt r_<Config_SCI0>_brif_interrupt r_<Config_SCI0>_callback_transmitend r_<Config_SCI0>_callback_receiveend r_<Config_SCI0>_callback_receiveerror r_<Config_SCI0>_callback_error
<Config_SCI0>.h
SCI/SCIF Clock Synchronous Mode
<Config_SCI0>.c
R_<Config_SCI0>_Create R_<Config_SCI0>_Start R_<Config_SCI0>_Stop R_<Config_SCI0>_Serial_Send R_<Config_SCI0>_Serial_Receive R_<Config_SCI0>_Serial_Send_Receive
<Config_SCI0>_user.c
R_<Config_SCI0>_Create_UserInit r_<Config_SCI0>_transmitend_interrupt r_<Config_SCI0>_transmit_interrupt r_<Config_SCI0>_receive_interrupt r_<Config_SCI0>_receiveerror_interrupt r_<Config_SCI0>_teif_interrupt r_<Config_SCI0>_txif_interrupt r_<Config_SCI0>_rxif_interrupt r_<Config_SCI0>_erif_interrupt r_<Config_SCI0>_brif_interrupt r_<Config_SCI0>_callback_transmitend r_<Config_SCI0>_callback_receiveend r_<Config_SCI0>_callback_receiveerror r_<Config_SCI0>_callback_error
<Config_SCI0>.h
Smart Configurator. 2. OUTPUT FILES
R20UT4360EJ0105 Rev.1.05 Page 17 of 533 Oct. 20, 2020
Table 2.11 Output File List (11/13)
Peripheral Function
File Name
API Function Name
Single Scan Mode S12AD
<Config_S12AD0>.c
R_<Config_S12AD0>_Create R_<Config_S12AD0>_Start R_<Config_S12AD0>_Stop R_<Config_S12AD0>_Get_ValueResult R_<Config_S12AD0>_Set_CompareValue R_<Config_S12AD0>_Set_CompareAValue R_<Config_S12AD0>_Set_CompareBValue
<Config_S12AD0>_user.c
R_<Config_S12AD0>_Create_UserInit r_<Config_S12AD0>_interrupt r_<Config_S12AD0>_compare_interrupt r_<Config_S12AD0>_compare_interruptA r_<Config_S12AD0>_compare_interruptB
<Config_S12AD0>.h
Smart Card Interface Mode
<Config_SCI0>.c
R_<Config_SCI0>_Create R_<Config_SCI0>_Start R_<Config_SCI0>_Stop R_<Config_SCI0>_SmartCard_Send R_<Config_SCI0>_SmartCard_Receive
<Config_SCI0>_user.c
R_<Config_SCI0>_Create_UserInit r_<Config_SCI0>_transmit_interrupt r_<Config_SCI0>_receive_interrupt r_<Config_SCI0>_receiveerror_interrupt r_<Config_SCI0>_callback_transmitend r_<Config_SCI0>_callback_receiveend r_<Config_SCI0>_callback_receiveerror
<Config_SCI0>.h
SPI Clock Synchronous Mode
<Config_RSPI0>.c
R_<Config_RSPI0>_Create R_<Config_RSPI0>_Start R_<Config_RSPI0>_Stop R_<Config_RSPI0>_Send R_<Config_RSPI0>_Send_Receive R_<Config_RSPI0>_SPI_Master_Send R_<Config_RSPI0>_SPI_Master_Send_Receive R_<Config_RSPI0>_SPI_Slave_Send R_<Config_RSPI0>_SPI_Slave_Send_Receive
<Config_RSPI0>_user.c
R_<Config_RSPI0>_Create_UserInit r_<Config_RSPI0>_receive_interrupt r_<Config_RSPI0>_transmit_interrupt r_<Config_RSPI0>_error_interrupt r_<Config_RSPI0>_idle_interrupt r_<Config_RSPI0>_transmitend_interrupt r_<Config_RSPI0>_receiveerror_interrupt r_<Config_RSPI0>_callback_receiveend r_<Config_RSPI0>_callback_transmitend r_<Config_RSPI0>_callback_error
<Config_RSPI0>.h
Smart Configurator. 2. OUTPUT FILES
R20UT4360EJ0105 Rev.1.05 Page 18 of 533 Oct. 20, 2020
Table 2.12 Output File List (12/13)
Peripheral Function
File Name
API Function Name
SPI Operation Mode
<Config_RSPI0>.c
R_<Config_RSPI0>_Create R_<Config_RSPI0>_Start R_<Config_RSPI0>_Stop R_<Config_RSPI0>_Send R_<Config_RSPI0>_Send_Receive
<Config_RSPI0>_user.c
R_<Config_RSPI0>_Create_UserInit r_<Config_RSPI0>_receive_interrupt r_<Config_RSPI0>_transmit_interrupt r_<Config_RSPI0>_error_interrupt r_<Config_RSPI0>_idle_interrupt r_<Config_RSPI0>_callback_receiveend r_<Config_RSPI0>_callback_transmitend r_<Config_RSPI0>_callback_error
<Config_RSPI0>.h
Voltage Detection Circuit
<Config_LVD1>.c
R_<Config_LVD1>_Create R_<Config_LVD1>_Start R_<Config_LVD1>_Stop
<Config_LVD1>_user.c
R_<Config_LVD1>_Create_UserInit r_<Config_LVD1>_lvdn_interrupt
<Config_LVD1>.h
Watchdog Timer
<Config_WDT>.c
R_<Config_WDT>_Create R_<Config_WDT>_Restart
<Config_WDT>_user.c
R_<Config_WDT>_Create_UserInit r_<Config_WDT>_wuni_interrupt r_<Config_WDT>_iwuni_interrupt r_<Config_WDT>_nmi_interrupt
<Config_WDT>.h
Continuous Scan
Mode DSAD
<Config_DSAD0>.c
R_<Ccnfig_DSAD0>_Create R_<Config_DSAD0>_Start R_<Config_DSAD0>_Stop R_<Config_DSAD0>_Set_SoftwareTrigger R_<Config_DSAD0>_Get_ValueResult
<Config_DSAD0>_user.c
R_<Config_DSAD0>_Create_UserInit
r_<Config_DSAD0>_adin_interrupt r_<Config_DSAD0>_scanendn_interrupt
<Config_DSAD0>.h
-
Single Scan Mode
DSAD
<Config_DSAD0>.c
R_<Ccnfig_DSAD0>_Create
R_<Config_DSAD0>_Start
R_<Config_DSAD0>_Stop
R_<Config_DSAD0>_Set_SoftwareTrigger
R_<Config_DSAD0>_Get_ValueResult
<Config_DSAD0>_user.c
R_<Config_DSAD0>_Create_UserInit
r_<Config_DSAD0>_adin_interrupt r_<Config_DSAD0>_scanendn_interrupt
<Config_DSAD0>.h
-
Smart Configurator. 2. OUTPUT FILES
R20UT4360EJ0105 Rev.1.05 Page 19 of 533 Oct. 20, 2020
Table 2.13 Output File List (13/13)
Peripheral Function
File Name
API Function Name
Delta-Sigma
Modulator Interface
<Config_DSMIF0>.c
R_<Config_DSMIF0>_Create
R_<Config_DSMIF0>_Start
R_<Config_DSMIF0>_Stop
<Config_DSMIF0>_user.c
R_<Config_DSMIF0>_Create_UserInit
r_<Config_DSMIF0>_ocdin_interrupt
r_<Config_DSMIF0>_scdin_interrupt
r_<Config_DSMIF0>_sumein_interrupt
<Config_DSMIF0>.h
Analog Front End
<Config_AFE>.c
R_<Config_AFE>_Create
<Config>AFE>_user.c
R_<Config_AFE>_Create_UserInit
<Config_AFE>.h
Motor (Complementary
PWM Mode Timer,
Single Scan Mode S12AD)
<Config_MTU3_MTU4>.c
R_<Config_MTU3_MTU4>_Create
R_<Config_MTU3_MTU4>_StartTimerCount
R_<Config_MTU3_MTU4>_StopTimerCount
R_<Config_MTU3_MTU4>_StartTimerCtrl
R_<Config_MTU3_MTU4>_StopTimerCtrl
R_<Config_MTU3_MTU4>_UpdDuty
R_<Config_MTU3_MTU4>_StartAD
R_<Config_MTU3_MTU4>_StopAD
R_<Config_MTU3_MTU4>_AdcGetConvVal
<Config_MTU3_MTU4>_user.c
R_<Config_MTU3_MTU4>_Create_UserInit
r_<Config_MTU3_MTU4>_CrestInterrupt
r_<Config_MTU3_MTU4>_ad_interrupt
<Config_MTU3_MTU4>.h

Smart Configurator. 3. INITIALIZATION

R20UT4360EJ0105 Rev.1.05 Page 20 of 533 Oct. 20, 2020
3.
INITIALIZATION
This chapter describes the flow of initialization by the API functions of the Code Generator.
PowerOn_Reset_PC
Sets interrupt table resister
Sets exception table resister
Sets single-precision floating-point status word
mcu_clock_setup
Initializes system clock
Initializes CLKOUT pin output
User’s pre process when worm start
Initializes C runtime environment
bsp_maapped_interrupt_open
Initializes mapped interrupt
bsp_ram_initialize
Initializes RAM
hardware_setup
Configures the ROM cache function
Configures the port and pin direction
Configures interrupts used
bsp_register_protect_open
Initializes variables needed for register
protection unctionality
bsp_interrupt_open
Initializes callback function array
init_iolib
Initializes C library
R_Systeminit
Initializes peripheral functions
bsp_non_existent_port_init Initializes non existent pins
bsp_adc_initial_configure
Configures the ADC initial settings
bsp_bsc_initial_configure
Configures the BUS initial settings
Sets processor status word
Enable the bus error interruopt
Main function
Process of blue box is FIT board support
package module.
Please refer to the application note (R01AN1685) for details.

Smart Configurator. 4. API FUNCTIONS

R20UT4360EJ0105 Rev.1.05 Page 21 of 533 Oct. 20, 2020
4.
API FUNCTIONS
This chapter describes the API functions output that are output by the Code Generator.

4.1 Overview

The following are the naming conventions for the API functions output by the Code Generator.
- Macro names These are in all-capital letters.
Note that if a name includes a number as a prefix, the relevant number is equal to the hexadecimal
value of the macro.
- Local variable names These are in low-case letters only.
- Global variable names
These are prefixed with “g”, and only the first letters of words that are elements of the names are
capitals.
- Names of pointers to global variables
These are prefixed with “gp”, and only the first letters of words that are elements of the names are
capitals.
- Names of elements in enumeration specifiers “enum” These are in all-capital letters.
Remarks In the generated code by the smart configurator, the for statement, the while statement,
the do-while statement (loop processing) are used in register setting reflected waiting process etc. If fail-safe processing for infinite loop is required, check the generated code and add processing.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 22 of 533 Oct. 20, 2020

4.2 Function Reference

This section describes the API functions output by the Code Generator, using the following notation format.
Figure 4.1 Notation Format of API Functions
(1) Name
Indicates the name of the API function.
(2) Outline
Outlines the functions of the API function
(3) [Syntax]
Indicates the format to be used when describing an API function to be called in C language.
(4) [Argument(s)]
API function arguments are explained in the following format.
I/O
Argument
Descripton
(a)
(b)
(c)
(a) I/O Argument classification I Input argument O Output argument (b) Argument Argument data type (c) Description Description of argument
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 23 of 533 Oct. 20, 2020
(5) [Return value]
API function return value is explained in the following format.
Macro
Description
(a)
(b)
(a) Macro Macro of return value (b) Description Description of return value
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 24 of 533 Oct. 20, 2020

4.2.1 Common

The Code Generator outputs the following API functions that are for common use by all peripheral
modules.
Table 4.1 Common API Functions
API Function Name
Description
r_undefined_exception
Executes processing in response to undefined instruction exceptions.
PowerON_Reset
Executes processing in response to a reset having been applied.
hardware_setup
Executes initialization processing that is required before controlling various hardware facilities.
R_Systeminit
Executes initialization processing that is required before controlling various peripheral modules.
R_CGC_Create
Executes initialization processing that is required before controlling the clock generation circuit.
R_CGC_Create_UserInit
Executes user-specific initialization processing for the clock generation circuit.
R_Interrupt_Create
Applies the settings for group interrupts and fast interrupts that were specified on the [Interrupts] tabbed page.
R_Pins_Create
Applies the settings for the multi-function pin controller that were specified on the [Pins] tabbed page.
main
main function.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 25 of 533 Oct. 20, 2020
r_undefined_exception
This API function executes processing in response to undefined instruction exceptions.
Remark: This API function is called as the interrupt handler for undefined instruction exceptions, which
occur when the attempted execution of an undefined instruction (an instruction that is not implemented) is detected.
[Syntax]
void r_undefined_exception ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 26 of 533 Oct. 20, 2020
PowerON_Reset
This API function executes processing in response to a reset having been applied. Remark: This API function is called as the interrupt handler for internal resets generated by the
power-on reset circuit.
[Syntax]
void PowerON_Reset ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 27 of 533 Oct. 20, 2020
hardware_setup
This API function executes initialization processing that is required before controlling various hardware
facilities.
Remark: This API function is called from PowerON_Reset as a callback routine.
[Syntax]
void hardware_setup ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 28 of 533 Oct. 20, 2020
R_Systeminit
This API function executes initialization processing that is required before controlling various peripheral
modules.
Remark: This API function is called from hardware_setup as a callback routine.
[Syntax]
void R_Systeminit ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 29 of 533 Oct. 20, 2020
R_CGC_Create
This API function executes initialization processing that is required before controlling the clock
generation circuit.
Remark: This API function is called from R_Systeminit before the main() function is executed.
[Syntax]
void R_CGC_Create ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 30 of 533 Oct. 20, 2020
R_CGC_Create_UserInit
This API function executes user-specific initialization processing for the clock generation circuit. Remark: This API function is called from R_CGC_Create as a callback routine.
[Syntax]
void R_CGC_Create_UserInit ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 31 of 533 Oct. 20, 2020
R_Interrupt_Create
This API function makes settings for group interrupts and fast interrupts. Remark: This API function is called fromR_Systeminit before the main() function is executed.
[Syntax]
void R_Interrupt_Create ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 32 of 533 Oct. 20, 2020
R_Pins_Create
This API function makes settings for the multi-function pin controller.
[Syntax]
void R_Pin_Create ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 33 of 533 Oct. 20, 2020
main
This is the main function. Remark This API function is called from PowerON_Reset as a callback routine.
[Syntax]
void main ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 34 of 533 Oct. 20, 2020

4.2.2 8-Bit timer

The Code Generator outputs the following API functions for the 8-bit timer.
Table 4.2 API Functions: [8-bit timer]
API Function Name
Function
R_<Config_TMR0>_Create
Executes initialization processing that is required before controlling the 8-bit timer.
R_<Config_TMR0>_Start
Starts counting by the counter.
R_<Config_TMR0>_Stop
Stops counting by the counter.
R_<Config_TMR0>_Create_UserInit
Executes user-specific initialization processing for the 8-bit timer.
r_<Config_TMR0>_cmimn_interrupt
Executes processing in response to compare match interrupts.
r_<Config_TMR0>_ovin_interrupt
Executes processing in response to overflow interrupts.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 35 of 533 Oct. 20, 2020
R_<Config_TMR0>_Create
This API function executes initialization processing that is required before controlling the 8-bit timer. Remark This API function is called from R_Systeminit before the main() function is executed.
[Syntax]
void R_<Config_TMR0>_Create ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 36 of 533 Oct. 20, 2020
R_<Config_TMR0>_Start
This API function Starts counting by the counter.
[Syntax]
void R_<Config_TMR0>_Start ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 37 of 533 Oct. 20, 2020
R_<Config_TMR0>_Stop
This API function stops counting by the counter.
[Syntax]
void R_<Config_TMR0>_Stop ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 38 of 533 Oct. 20, 2020
R_<Config_TMR0>_Create_UserInit
This API function executes user-specific initialization processing for the 8-bit timer. Remark This API function is called from R_<Config_TMR0>_Create as a callback routine.
[Syntax]
void R_<Config_TMR0>_Create_UserInit ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 39 of 533 Oct. 20, 2020
r_<Config_TMR0>_cmimn_interrupt
The API function executes processing in response to compare match interrupts.
[Syntax]
static void r_<Config_TMR0>_cmimn_interrupt ( void );
Remark n is the channel number and m is the number of a timer constant register.
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 40 of 533 Oct. 20, 2020
r_<Config_TMR0>_ovin_interrupt
This API function executes processing in response to overflow interrupts.
[Syntax]
static void r_<Config_TMR0>_ovin_interrupt ( void );
Remark n is the channel number.
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 41 of 533 Oct. 20, 2020
Usage example
Use timer as One-shot timer.
[API setting example]
r_cg_main.c
void main(void) {
R_MAIN_UserInit(); /* Start user code. Do not edit comment generated here */
/* Start TMR channel 0 counter */ R_TMR0_Start();
while (1U) { ; }
/* End user code. Do not edit comment generated here */
}
r_cg_tmr_user.c
static void r_tmr_cmia0_interrupt(void) {
/* Start user code. Do not edit comment generated here */
/* Stop TMR channel 0 counter */ R_TMR0_Stop();
/* End user code. Do not edit comment generated here */ }
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 42 of 533 Oct. 20, 2020

4.2.3 Buses

The Code Generator outputs the following API functions for the bus.
Table4.3 API Functions: [Buses]
API Function Name
Function
R_<Config_BSC>_Create
Executes initialization processing that is required before controlling the bus.
R_<Config_BSC>_Error_Monitoring_Start
Enables the detection of bus errors due to access to illegal addresses.
R_<Config_BSC>_Error_Monitoring_Stop
Disables the detection of bus errors due to access to illegal addresses.
R_<Config_BSC>_InitializeSDRAM
Initializes the SDRAM controller.
R_<Config_BSC>_Create_UserInit
Executes user-specific initialization processing for the bus.
r_<Config_BSC>_buserr_interrupt
Executes processing in response to bus errors due to access to illegal addresses.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 43 of 533 Oct. 20, 2020
R_<Config_BSC>_Create
This API function executes initialization processing that is required before controlling the bus. Remark This API function is called from R_Systeminit before the main() function is executed.
[Syntax]
void R_<Config_BSC>_Create ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 44 of 533 Oct. 20, 2020
R_<Config_BSC>_Error_Monitoring_Start
This API function enables the detection of bus errors due to access to illegal addresses.
[Syntax]
void R_<Config_BSC>_Error_Monitoring_Start ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 45 of 533 Oct. 20, 2020
R_<Config_BSC>_Error_Monitoring_Stop
This API function disables the detection of bus errors due to access to illegal addresses.
[Syntax]
void R_<Config_BSC>_Error_Monitoring_Stop ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 46 of 533 Oct. 20, 2020
R_<Config_BSC>_InitializeSDRAM
his API function initializes the SDRAM controller.
[Syntax]
void R_<Config_BSC>_InitializeSDRAM ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 47 of 533 Oct. 20, 2020
R_<Config_BSC>_Create_UserInit
This API function executes user-specific initialization processing for the bus. Remark This API function is called from R_<Config_BSC>_Create as a callback routine.
[Syntax]
void R_<Config_BSC>_Create_UserInit ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 48 of 533 Oct. 20, 2020
r_<Config_BSC>_buserr_interrupt
This API function executes processing in response to bus errors due to access to illegal addresses. Remark1 This API function is called as the interrupt handler for bus errors due to access by a program
to locations in illegal address areas.
Remark2 This API function can be used to determine the bus master that caused the current bus
error; to do so, write the processing for reading the MST bits in bus error status register 1
(BERSR1) within this function.
Remark3 This API function can be used to determine the illegal address (the high-order 13 bits of the
address) to which access caused the current bus error; to do so, write the processing for
reading the ADDR bits in bus error status register 2 (BERSR2) within this function.
[Syntax]
void r_<Config_BSC>_buserr_interrupt ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 49 of 533 Oct. 20, 2020
Usage example
Acquiring the address to which access caused a bus error:
main.c
#include "r_smc_entry.h" void main(void) {
/* Enable BUSERR interrupt in ICU */ R_Config_BSC_Error_Monitoring_Start();
while (1U) { nop(); }
}
Config_BSC_user.c
/* Start user code for global. Do not edit comment generated here */
volatile uint16_t g_bsc_buserr_addr;
/* End user code. Do not edit comment generated here */ void r_Config_BSC_buserr_interrupt(void)
{
/* Start user code for r_Config_BSC_buserr_interrupt. Do not edit comment generated here */
/* Restore an address that was accessed when a bus error occurred */ if (1U == BSC.BERSR1.BIT.IA) { g_bsc_buserr_addr = ((uint16_t)(BSC.BERSR2.WORD)>>3U); }
/* Clear the bus error status registers */ BSC.BERCLR.BIT.STSCLR = 1U;
/* End user code. Do not edit comment generated here */ }
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 50 of 533 Oct. 20, 2020

4.2.4 Clock Frequency Accuracy Measurement Circuit

The Code Generator outputs the following API functions for the clock frequency accuracy measurement
circuit (CAC).
Table4.4 API Functions: [Clock Frequency Accuracy Measurement Circuit]
API Function Name
Function
R_<Config_CAC>_Create
Executes initialization processing that is required before controlling the clock frequency accuracy measurement circuit.
R_<Config_CAC>_Start
Starts measurement of the clock frequency accuracy.
R_<Config_CAC>_Stop
Stops measurement of the clock frequency accuracy.
R_<Config_CAC>_Create_UserInit
Executes user-specific initialization processing for the clock frequency accuracy measurement circuit.
r_<Config_CAC>_mendf_interrupt
Executes processing in response to measurement end interrupts. (The name of this API function varies with the device group.)
r_<Config_CAC>_mendi_interrupt
r_<Config_CAC>_ferrf_interrupt
Executes processing in response to frequency error interrupts. (The name of this API function varies with the device group.)
r_<Config_CAC>_ferri_interrupt
r_<Config_CAC>_ovff_interrupt
Executes processing in response to overflow interrupts. (The name of this API function varies with the device group.)
r_<Config_CAC>_ovfi_interrupt
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 51 of 533 Oct. 20, 2020
R_<Config_CAC>_Create
This API function executes initialization processing that is required before controlling the clock frequency
accuracy measurement circuit.
Remark This API function is called from R_Systeminit before the main() function is executed.
[Syntax]
void R_<Config_CAC>_Create ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 52 of 533 Oct. 20, 2020
R_<Config_CAC>_Start
This API function starts measurement of the clock frequency accuracy.
[Syntax]
void R_<Config_CAC>_Start ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 53 of 533 Oct. 20, 2020
R_<Config_CAC>_Stop
This API function stops measurement of the clock frequency accuracy.
[Syntax]
void R_<Config_CAC>_Stop ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 54 of 533 Oct. 20, 2020
R_<Config_CAC>_Create_UserInit
This API function executes user-specific initialization processing for the clock frequency accuracy
measurement circuit (CAC).
Remark This API function is called from R_<Config_CAC>_Create as a callback routine.
[Syntax]
void R_<Config_CAC>_Create_UserInit ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 55 of 533 Oct. 20, 2020
r_<Config_CAC>_mendf_interrupt
r_<Config_CAC>_mendi_interrupt
This API function executes processing in response to measurement end interrupts. Remark This API function is called as the interrupt handler for measurement end interrupts, which
occur when the clock frequency accuracy measurement circuit detects valid edges on the
reference signal line.
[Syntax]
void r_<Config_CAC>_mendf_interrupt ( void );
void r_<Config_CAC>_mendi_interrupt ( void );
Remark The name of this API function varies with the device group.
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 56 of 533 Oct. 20, 2020
r_<Config_CAC>_ferrf_interrupt
r_<Config_CAC>_ferri_interrupt
This API function executes processing in response to measurement end interrupts. Remark This API function is called as the interrupt handler for measurement end interrupts, which
occur when the clock frequency accuracy measurement circuit detects valid edges on the
reference signal line.
[Syntax]
void r_<Config_CAC>_ferrf_interrupt ( void );
void r_<Config_CAC>_ferri_interrupt ( void );
Remark The name of this API function varies with the device group.
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 57 of 533 Oct. 20, 2020
r_<Config_CAC>_ovff_interrupt
r_<Config_CAC>_ovfi_interrupt
This API function executes processing in response to overflow interrupts. Remark This API function is called as the interrupt handler for overflow interrupts, which occur when
the counter value overflows.
[Syntax]
void r_<Config_CAC>_ovff_interrupt ( void );
void r_<Config_CAC>_ovfi_interrupt ( void );
Remark The name of this API function varies with the device group.
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 58 of 533 Oct. 20, 2020
Usage example
Counting the number of frequency errors:
main.c
#include "r_smc_entry.h" void main(void) {
/* Enable clock frequency measurement */ R_Config_CAC_Start();
while (1U) { nop(); }
}
Config_CAC_user.c
/* Start user code for global. Do not edit comment generated here */
volatile uint8_t g_cac_ferri_cnt;
/* End user code. Do not edit comment generated here */ void R_Config_CAC_Create_UserInit(void)
{
/* Start user code for user init. Do not edit comment generated here */
/* Reset the error countor */ g_cac_ferri_cnt = 0U;
/* End user code. Do not edit comment generated here */
} void r_Config_CAC_ferri_interrupt(void)
{
/* Start user code for r_Config_CAC_ferri_interrupt. Do not edit comment generated here */
/* Add the error countor */ g_cac_ferri_cnt++;
/* End user code. Do not edit comment generated here */ }
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 59 of 533 Oct. 20, 2020

4.2.5 Comparator

The Code Generator outputs the following API functions for the comparator.
Table4.5 API Functions: [Comparator]
API Function Name
Function
R_<Config_CMPB0>_Create
The Code Generator outputs the following API functions for the comparator.
R_<Config_CMPB0>_Start
The Code Generator outputs the following API functions for the comparator.
R_<Config_CMPB0>_Stop
The Code Generator outputs the following API functions for the comparator.
R_<Config_CMPB0>_Create_UserInit
The Code Generator outputs the following API functions for the comparator.
r_<Config_CMPB0>_cmpbn_interrupt
The Code Generator outputs the following API functions for the comparator.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 60 of 533 Oct. 20, 2020
R_<Config_CMPB0>_Create
This API function executes initialization processing that is required before controlling the comparator. Remark This API function is called from R_Systeminit before the main() function is executed.
[Syntax]
void R_<Config_CMPB0>_Create ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 61 of 533 Oct. 20, 2020
R_<Config_CMPB0>_Start
This API function starts comparison of the analog input voltage with the reference voltage.
[Syntax]
void R_<Config_CMPB0>_Start ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 62 of 533 Oct. 20, 2020
R_<Config_CMPB0>_Stop
This API function stops comparison of the analog input voltage with the reference voltage.
[Syntax]
void R_<Config_CMPB0>_Stop ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 63 of 533 Oct. 20, 2020
R_<Config_CMPB0>_Create_UserInit
This API function executes user-specific initialization processing for the comparator. Remark This API function is called from R_<Config_CMPB0>_Create as a callback routine.
[Syntax]
void R_<Config_CMPB0>_Create_UserInit ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 64 of 533 Oct. 20, 2020
r_<Config_CMPB0>_cmpbn_interrupt
This API function executes processing in response to comparator Bn interrupts. Remark This API function is called as the interrupt handler for comparator Bn interrupts, which occur
when the result of comparison of the analog input voltage with the reference input voltage
changes.
[Syntax]
void r_<Config_CMPB0>_cmpbn_interrupt ( void );
Remark n is a channel number.
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 65 of 533 Oct. 20, 2020
Usage example
Setting a flag when the result of comparison changes:
main.c
#include "r_smc_entry.h" void main(void) {
/* Start comparator B0 */ R_Config_CMPB0_Start();
while (1U) { nop(); }
}
Config_CMPB0_user.c
/* Start user code for global. Do not edit comment generated here */
volatile uint8_t g_cmpb0_f;
/* End user code. Do not edit comment generated here */ void R_Config_CMPB0_Create_UserInit(void)
{
/* Start user code for user init. Do not edit comment generated here */
/* Clear the flag */ g_cmpb0_f = 0U;
/* End user code. Do not edit comment generated here */
} static void r_Config_CMPB0_cmpb0_interrupt(void)
{ /* Start user code for r_Config_CMPB0_cmpb0_interrupt. Do not edit comment generated here */
/* Set the flag */ g_cmpb0_f = 1U;
/* End user code. Do not edit comment generated here */ }
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 66 of 533 Oct. 20, 2020

4.2.6 Compare Match Timer

The Code Generator outputs the following API functions for compare match timers (CMT or CMTW).
Table4.6 API Functions: [Compare Match Timer]
API Function Name
Function
R_<Config_CMT0>_Create
Executes initialization processing that is required before controlling a compare match timer (CMT or CMTW).
R_<Config_CMT0>_Start
Starts counting by the counter.
R_<Config_CMT0>_Stop
Stops counting by the counter.
R_<Config_CMT0>_Create_UserInit
Executes user-specific initialization processing for a compare match timer (CMT or CMTW).
r_<Config_CMT0>_cmin_interrupt
Executes processing in response to compare match interrupts (CMIn).
r_<Config_CMT0>_cmwin_interrupt
Executes processing in response to compare match interrupts (CMWIn).
r_<Config_CMT0>_icmin_interrupt
Executes processing in response to input capture interrupts.
r_<Config_CMT0>_ocmin_interrupt
Executes processing in response to output compare interrupts.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 67 of 533 Oct. 20, 2020
R_<Config_CMT0>_Create
This API function executes initialization processing that is required before controlling a compare match
timer (CMT or CMTW).
Remark This API function is called from R_Systeminit before the main() function is executed.
[Syntax]
void R_<Config_CMT0>_Create ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 68 of 533 Oct. 20, 2020
R_<Config_CMT0>_Start
This API function starts counting by the counter.
[Syntax]
void R_<Config_CMT0>_Start ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 69 of 533 Oct. 20, 2020
R_<Config_CMT0>_Stop
This API function stops counting by the counter.
[Syntax]
void R_<Config_CMT0>_Stop ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 70 of 533 Oct. 20, 2020
R_<Config_CMT0>_Create_UserInit
This API function executes user-specific initialization processing for a compare match timer (CMT or
CMTW).
Remark This API function is called from R_<Config_CMT0>_Create as a callback routine.
[Syntax]
void R_<Config_CMT0>_Create_UserInit ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 71 of 533 Oct. 20, 2020
r_<Config_CMT0>_cmin_interrupt
This API function executes processing in response to compare match interrupts (CMIn). Remark This API function is called as the interrupt handler for compare match interrupts (CMIn),
which occur when the current counter value (the value of the compare match timer counter (CMCNT)) matches a specified value (the value of the compare match timer constant
register (CMCOR)).
[Syntax]
void r_<Config_CMT0>_cmin_interrupt ( void );
Remark n is a channel number.
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 72 of 533 Oct. 20, 2020
r_<Config_CMT0>_cmwin_interrupt
This API function executes processing in response to compare match interrupts (CMWIn). Remark This API function is called as the interrupt handler for compare match interrupts (CMWIn),
which occur when the current counter value (the value of the compare match timer counter (CMWCNT)) matches a specified value (the value of the compare match timer constant
register (CMWCOR)).
[Syntax]
void r_<Config_CMT0>_cmwin_interrupt ( void );
Remark n is a channel number.
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 73 of 533 Oct. 20, 2020
r_<Config_CMT0>_icmin_interrupt
This API function executes processing in response to input capture interrupts.
[Syntax]
void r_<Config_CMT0>_icmin_interrupt ( void );
Remark n is a channel number.
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 74 of 533 Oct. 20, 2020
r_<Config_CMT0>_ocmin_interrupt
This API function executes processing in response to output compare interrupts.
[Syntax]
void r_<Config_CMT0>_ocmin_interrupt ( void );
Remark n is a channel number.
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 75 of 533 Oct. 20, 2020
Usage example
With the timer operating in a one-shot manner:
main.c
#include "r_smc_entry.h" void main(void) {
/* Start CMT channel 0 counter */ R_Config_CMT0_Start();
while (1U) { nop(); }
}
Config_CMT0_user.c
static void r_Config_CMT0_cmi0_interrupt(void) {
/* Start user code for r_Config_CMT0_cmi0_interrupt. Do not edit comment generated here */
/* Stop CMT channel 0 counter */ R_Config_CMT0_Stop();
/* End user code. Do not edit comment generated here */ }
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 76 of 533 Oct. 20, 2020

4.2.7 Complementary PWM Mode Timer

The Code Generator outputs the following API functions for timers in complementary PWM mode.
Table4.7 API Functions: [Complementary PWM Mode Timer]
API Function Name
Function
R_<Config_MTU3_MTU4>_Create
Executes initialization processing that is required before controlling a timer in complementary PWM mode.
R_<Config_MTU3_MTU4>_Start
Starts counting by the counter.
R_<Config_MTU3_MTU4>_Stop
Stops counting by the counter.
R_<Config_MTU3_MTU4>_Create_UserInit
Executes user-specific initialization processing for a timer in complementary PWM mode.
r_<Config_MTU3_MTU4>_tgimn_interrupt
Executes processing in response to compare match interrupts.
r_<Config_MTU3_MTU4>_cj_tgimj_interrupt
Executes processing in response to compare match interrupts.
r_<Config_MTU3_MTU4>_cj_tcivj_interrupt
Executes processing in response to underflow interrupts.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 77 of 533 Oct. 20, 2020
R_<Config_MTU3_MTU4>_Create
This API function executes initialization processing that is required before controlling a timer in
complementary PWM mode.
Remark This API function is called from R_Systeminit before the main() function is executed.
[Syntax]
void R_<Config_MTU3_MTU4>_Create ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 78 of 533 Oct. 20, 2020
R_<Config_MTU3_MTU4>_Start
This API function starts counting by the counter.
[Syntax]
void R_<Config_MTU3_MTU4>_Start ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 79 of 533 Oct. 20, 2020
R_<Config_MTU3_MTU4>_Stop
This API function stops counting by the counter.
[Syntax]
void R_<Config_MTU3_MTU4>_Stop ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 80 of 533 Oct. 20, 2020
R_<Config_MTU3_MTU4>_Create_UserInit
This API function executes user-specific initialization processing for a timer in complementary PWM mode. Remark This API function is called from R_<Config_MTU3_MTU4>_Create as a callback routine.
[Syntax]
void R_<Config_MTU3_MTU4>_Create_UserInit ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 81 of 533 Oct. 20, 2020
r_<Config_MTU3_MTU4>_tgimn_interrupt
This API function executes processing in response to compare match interrupts. Remark This API function is called as the interrupt handler for compare match interrupts, which
occur when the current counter value (the value of the timer counter (TCNT)) matches a
specified value (the value of the timer general register (TGR)).
[Syntax]
void r_<Config_MTU3_MTU4>_tgimn_interrupt ( void );
Remark n is channel numbers, and m is the number of a timer general register.
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 82 of 533 Oct. 20, 2020
r_<Config_MTU3_MTU4>_cj_tgimj_interrupt
This API function executes processing in response to compare match interrupts. Remark This API function is called as the interrupt handler for compare match interrupts, which
occur when the current counter value (the value of the timer counter (TCNT)) matches a
specified value (the value of the timer general register (TGR)).
[Syntax]
void r_<Config_MTU3_MTU4>_cj_tgimj_interrupt ( void );
Remark n is channel numbers, and m is the number of a timer general register.
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 83 of 533 Oct. 20, 2020
r_<Config_MTU3_MTU4>_cj_tcivj_interrupt
This API function executes processing in response to compare match interrupts. Remark This API function is called as the interrupt handler for compare match interrupts, which
occur when the current counter value (the value of the timer counter (TCNT)) matches a
specified value (the value of the timer general register (TGR)).
[Syntax]
void r_<Config_MTU3_MTU4>_cj_tcivj_interrupt ( void );
Remark j is channel number.
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 84 of 533 Oct. 20, 2020
Usage example
Repeating processing to gradually increase the width of the U-phase pulses to the upper limit and then
gradually reduce it to the lower limit:
main.c
#include "r_smc_entry.h" void main(void) {
/* Start the MTU6 channel counter */ R_Config_MTU6_MTU7_Start();
while (1U) { nop(); } }
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 85 of 533 Oct. 20, 2020
Config_MTU6_MTU7_user.c
/* Start user code for global. Do not edit comment generated here */
volatile uint16_t gu_pulse_u; volatile int8_t g_pulse_dir_u; /* End user code. Do not edit comment generated here */
void R_Config_MTU6_MTU7_Create_UserInit(void) {
/* Start user code for user init. Do not edit comment generated here */
gu_pulse_u = _xxxx_6TGRB_VALUE; g_pulse_dir_u = 1U;
/* End user code. Do not edit comment generated here */
} static void r_Config_MTU6_MTU7_tgib6_interrupt(void)
{ /* Start user code for r_Config_MTU6_MTU7_tgib6_interrupt. Do not edit comment generated here */
gu_pulse_u += g_pulse_dir_u; if(gu_pulse_u == _xxxx_TCDRB_VALUE) { g_pulse_dir_u = -1; } else if(gu_pulse_u == _xxxx_TDDRB_VALUE) { g_pulse_dir_u = 1; } MTU6.TGRB = gu_pulse_u; MTU6.TGRD = gu_pulse_u;
/* End user code. Do not edit comment generated here */ }
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 86 of 533 Oct. 20, 2020

4.2.8 Continuous Scan Mode S12AD

The Code Generator outputs the following API functions for the continuous scan mode S12AD.
Table4.8 API Functions: [Countinuous Scan Mode S12AD]
API Function Name
Function
R_<Config_S12AD0>_Create
Executes initialization processing that is required before controlling the S12AD in continuous scan mode.
R_<Config_S12AD0>_Start
Starts A/D conversion.
R_<Config_S12AD0>_Stop
Stops A/D conversion.
R_<Config_S12AD0>_Get_ValueResult
Gets the result of conversion.
R_<Config_S12AD0>_Set_CompareValue
Sets the compare level.
R_<Config_S12AD0>_Set_CompareAValue
Sets the compare level for window A.
R_<Config_S12AD0>_Set_CompareBValue
Sets the compare level for window B.
R_<Config_S12AD0>_Create_UserInit
Executes user-specific initialization processing for the S12AD in continuous scan mode.
r_<Config_S12AD0>_interrupt
Executes processing in response to scan end interrupts.
r_<Config_S12AD0>_compare_interrupt
Executes processing in response to compare interrupts.
r_<Config_S12AD0>_compare_interruptA
Executes processing in response to compare interrupts for window A.
r_<Config_S12AD0>_compare_interruptB
Executes processing in response to compare interrupts for window B.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 87 of 533 Oct. 20, 2020
R_<Config_S12AD0>_Create
This API function executes initialization processing that is required before controlling the continuous
scan mode S12AD.
Remark This API function is called from R_Systeminit before the main() function is executed.
[Syntax]
void R_<Config_S12AD0>_Create ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 88 of 533 Oct. 20, 2020
R_<Config_S12AD0>_Start
This API function starts A/D conversion.
[Syntax]
void R_<Config_S12AD0>_Start ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 89 of 533 Oct. 20, 2020
R_<Config_S12AD0>_Stop
This API function stops A/D conversion.
[Syntax]
void R_<Config_S12AD0>_Stop ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 90 of 533 Oct. 20, 2020
R_<Config_S12AD0>_Get_ValueResult
This API function gets the result of conversion.
[Syntax]
void R_<Config_S12AD0>_Get_ValueResult ( ad_channel_t channel, uint16_t * const buffer );
[Argument(s)]
For RX130 or RX230/RX231
I/O
Argument
Description
I
ad_channel_t channel;
Channel number
ADCHANNEL0: Input channel AN000 ADCHANNEL1: Input channel AN001 ADCHANNEL2: Input channel AN002 ADCHANNEL3: Input channel AN003 ADCHANNEL4: Input channel AN004 ADCHANNEL5: Input channel AN005 ADCHANNEL6: Input channel AN006 ADCHANNEL7: Input channel AN007 ADCHANNEL16: Input channel AN016 ADCHANNEL17: Input channel AN017 ADCHANNEL18: Input channel AN018 ADCHANNEL19: Input channel AN019 ADCHANNEL20: Input channel AN020 ADCHANNEL21: Input channel AN021 ADCHANNEL22: Input channel AN022 ADCHANNEL23: Input channel AN023 ADCHANNEL24: Input channel AN024 ADCHANNEL25: Input channel AN025 ADCHANNEL26: Input channel AN026 ADCHANNEL27: Input channel AN027 ADCHANNEL28: Input channel AN028 ADCHANNEL29: Input channel AN029 ADCHANNEL30: Input channel AN030 ADCHANNEL31: Input channel AN031
ADTEMPSENSOR: Extended analog input (temperature
sensor output)
ADINTERREFVOLT: Extended analog input (internal
reference voltage) ADSELFDIAGNOSIS: Result of self-diagnosis ADDATADUPLICATION: Double-trigger mode result
O
uint16_t * const buffer;
Pointer to the location where the acquired results of conversion
are to be stored
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 91 of 533 Oct. 20, 2020
For other devices
I/O
Argument
Description
I
ad_channel_t channel;
Channel number
ADCHANNEL0: Input channel AN000 ADCHANNEL1: Input channel AN001 ADCHANNEL2: Input channel AN002 ADCHANNEL3: Input channel AN003 ADCHANNEL4: Input channel AN004 ADCHANNEL5: Input channel AN005 ADCHANNEL6: Input channel AN006 ADCHANNEL7: Input channel AN007 ADCHANNEL8: Input channel AN008 ADCHANNEL9: Input channel AN009 ADCHANNEL10: Input channel AN010 ADCHANNEL11: Input channel AN011 ADCHANNEL12: Input channel AN012 ADCHANNEL13: Input channel AN013 ADCHANNEL14: Input channel AN014 ADCHANNEL15: Input channel AN015 ADCHANNEL16: Input channel AN016 ADCHANNEL17: Input channel AN017 ADCHANNEL18: Input channel AN018 ADCHANNEL19: Input channel AN019 ADCHANNEL20: Input channel AN020
ADTEMPSENSOR: Extended analog input (temperature
sensor output)
ADINTERREFVOLT: Extended analog input (internal
reference voltage) ADSELFDIAGNOSIS: Result of self-diagnosis ADDATADUPLICATION: Double-trigger mode result ADDATADUPLICATIONA: Double-trigger mode A result ADDATADUPLICATIONB: Double-trigger mode B result
O
uint16_t * const buffer;
Pointer to the location where the acquired results of conversion
are to be stored
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 92 of 533 Oct. 20, 2020
R_<Config_S12AD0>_Set_CompareValue
This API function sets the compare level.
[Syntax]
void R_<Config_S12AD0>_Set_CompareValue ( uint16_t reg_value0, uint16_t reg_value1);
[Argument(s)]
I/O
Argument
Description
I
uint16_t reg_value0;
Value to be set in compare register 0
I
uint16_t reg_value1;
Value to be set in compare register 1
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 93 of 533 Oct. 20, 2020
R_<Config_S12AD0>_Set_CompareAValue
This API function sets the compare level for window A.
[Syntax]
void R_<Config_S12AD0>_Set_CompareAValue ( uint16_t reg_value0, uint16_t reg_value1);
[Argument(s)]
I/O
Argument
Description
I
uint16_t reg_value0;
Value to be set in compare register 0
I
uint16_t reg_value1;
Value to be set in compare register 1
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 94 of 533 Oct. 20, 2020
R_<Config_S12AD0>_Set_CompareBValue
This API function sets the compare level for window B.
[Syntax]
void R_<Config_S12AD0>_Set_CompareBValue ( uint16_t reg_value0, uint16_t reg_value1);
[Argument(s)]
I/O
Argument
Description
I
uint16_t reg_value0;
Value to be set in compare register 0
I
uint16_t reg_value1;
Value to be set in compare register 1
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 95 of 533 Oct. 20, 2020
R_<Config_S12AD0>_Create_UserInit
This API function executes user-specific initialization processing for the continuous scan mode S12AD. Remark This API function is called from R_<Config_S12AD0>_Create as a callback routine.
[Syntax]
void R_<Config_S12AD0>_Create_UserInit ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 96 of 533 Oct. 20, 2020
r_<Config_S12AD0>_interrupt
This API function executes processing in response to scan end interrupts.
[Syntax]
void r_<Config_S12AD0>_interrupt ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 97 of 533 Oct. 20, 2020
r_<Config_S12AD0>_compare_interrupt
This API function executes processing in response to compare interrupts.
[Syntax]
void r_<Config_S12AD0>_compare_interrupt ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 98 of 533 Oct. 20, 2020
r_<Config_S12AD0>_compare_interruptA
This API function executes processing in response to compare interrupts for window A.
[Syntax]
void r_<Config_S12AD0>_compare_interruptA ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 99 of 533 Oct. 20, 2020
r_<Config_S12AD0>_compare_interruptB
This API function executes processing in response to compare interrupts for window B.
[Syntax]
void r_<Config_S12AD0>_compare_interruptB ( void );
[Argument(s)]
None.
[Return value]
None.
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 100 of 533 Oct. 20, 2020
Usage example
Getting the result of A/D conversion that matches the default setting of the condition for comparison and
then changing the compare match values:
main.c
#include "r_smc_entry.h" void main(void) {
/* Start the AD0 converter */ R_Config_S12AD0_Start();
while (1U) { nop(); }
}
Config_S12AD0_user.c
/* Start user code for global. Do not edit comment generated here */
volatile uint16_t g_s12ad0_ch000_value;
/* End user code. Do not edit comment generated here */ void r_Config_S12AD0_compare_interrupt(void)
{ /* Start user code for r_Config_S12AD0_compare_interrupt. Do not edit comment generated here */
/* Stop the AD0 converter */ R_Config_S12AD0_Stop();
/* Get result from the AD0 channel 0 (AN000) converter */ R_Config_S12AD0_Get_ValueResult(ADCHANNEL0, (uint16_t *)&g_s12ad0_ch000_value);
/* Set reference data for AD0 comparison */ R_Config_S12AD0_Set_CompareValue(1000U, 3000U);
/* Clear the compare flag */ S12AD.ADCMPSR0.WORD = 0x00U;
/* Start the AD0 converter */ R_Config_S12AD0_Start();
/* End user code. Do not edit comment generated here */ }
Smart Configurator. 4. API FUNCTIONS
R20UT4360EJ0105 Rev.1.05 Page 101 of 533 Oct. 20, 2020

4.2.9 CRC Calculator

The Code Generator outputs the following API functions for the CRC calculator.
Table4.9 API Functions: [CRC Calculato]
API Function Name
Function
R_<Config_CRC>_SetCRC8
Initializes the CRC calculator in preparation for 8-bit CRC calculation (polynomial: X8 + X2 + X + 1).
R_<Config_CRC>_SetCRC16
Initializes the CRC calculator in preparation for 16-bit CRC calculation (polynomial: X16 + X15 + X2 + 1).
R_<Config_CRC>_SetCCITT
Initializes the CRC calculator in preparation for 16-bit CRC calculation (polynomial: X16 + X12 + X5 + 1).
R_<Config_CRC>_SetCRC32
Initializes the CRC calculator in preparation for 32-bit CRC calculation (polynomial: X32 + X26 + X23 + X22 + X16 + X12 + X11 + X10 + X8 + X7 + X5 + X4 + X2 + X + 1).
R_<Config_CRC>_SetCRC32C
Initializes the CRC calculator in preparation for 32-bit CRC calculation (polynomial: X32 + X28 + X27 + X26 + X25 + X23 + X22 + X20 + X19 + X18 + X14 + X13 + X11 + X10 + X9 + X8 + X6 + 1).
R_<Config_CRC>_Input_Data
Sets the initial value of the data from which the CRC is to be calculated.
R_<Config_CRC>_Get_Result
Gets the result of the operation.
Loading...