User’s Manual 32 Renesas Peripheral Driver Library User’s Manual RX62N, RX621 Group 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). www.renesas.com Rev.1.
Notice 1. Descriptions of circuits, software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples. You are fully responsible for the incorporation of these circuits, software, and information in the design of your equipment. Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from the use of these circuits, software, or information. 2.
General Precautions in the Handling of MPU/MCU Products The following usage notes are applicable to all MPU/MCU products from Renesas. For detailed usage notes on the products covered by this document, refer to the relevant sections of the document as well as any technical updates that have been issued for the products. 1. Handling of Unused Pins Handle unused pins in accordance with the directions given under Handling of Unused Pins in the manual.
Table of Contents Table of Contents ............................................................................................................................................ 1-1 1. Introduction ............................................................................................................................................... 1-1 1.1. Tool chain requirements .................................................................................................................... 1-2 1.2.
2.17. 8-bit Timer Driver ............................................................................................................................. 2-14 2.18. Compare Match Timer Driver .......................................................................................................... 2-15 2.19. Real-time Clock Driver..................................................................................................................... 2-16 2.20. Watchdog Timer Driver ................................
3) 4.2.5. 1) 2) 4.2.6. 1) 2) 3) 4) 5) 4.2.7. 1) 4.2.8. 1) 2) 3) 4) 5) 6) 4.2.9. 1) 2) 3) 4) 4.2.10. 1) 2) 3) 4) 4.2.11. 1) 2) 3) 4) 5) 4.2.12. 1) 2) 3) 4) 5) 6) 7) 4.2.13. 1) 2) 3) 4) 4.2.14. 1) 2) 3) 4.2.15. 1) 2) 3) 4) 5) 6) 7) of 361 R_PFC_Modify .......................................................................................................................... 4-41 MCU operation ......................................................................................................................
8) 9) 10) 11) 4.2.16. 1) 2) 3) 4) 5) 4.2.17. 1) 2) 3) 4.2.18. 1) 2) 3) 4.2.19. 1) 2) 3) 4.2.20. 1) 2) 3) 4) 5) 6) 7) 4.2.21. 1) 2) 3) 4) 4.2.22. 1) 2) 3) 4) 5) 6) 7) 8) 9) 4.2.23. 1) 2) 3) 4) 5) 6) 4.2.24. 1) 2) 3) 4) 4.2.25. 1) 2) of 361 R_TMR_ControlUnit ................................................................................................................ 4-140 R_TMR_ControlPeriodic ..........................................................................................................
3) 4) 4.2.26. 1) 2) 3) 5. R_ADC_10_Control ................................................................................................................. 4-226 R_ADC_10_Read .................................................................................................................... 4-227 10-bit Digital to Analog Converter .......................................................................................... 4-228 R_DAC_10_Create ...............................................................
6. RX-specific notes ...................................................................................................................................... 6-1 6.1. Interrupts and processor mode ......................................................................................................... 6-1 6.2. Interrupts and DSP instructions ......................................................................................................... 6-1 Revision History ......................................
RX62N Group, RX621 Group 1. Introduction 1. Introduction The Renesas Peripheral Driver Library (RPDL) is a unified API for controlling the peripheral modules on the microcontrollers made by Renesas Electronics.
RX62N Group, RX621 Group 1.1. 1. Introduction Tool chain requirements This RPDL library has been built and tested using the C/C++ Compiler Package for RX Family V.1.02 Release 01. It cannot be used with older versions of the tool chain. The latest version of the tool chain can be downloaded from the Renesas Web site (Home / Products / Software and Tools / Coding Tools / C/C++ Compilers and Assemblers / C/C++ Compiler Package for RX Family /). 1.2.
RX62N Group, RX621 Group 1. Introduction 1.3. Using the library within your project The driver library can be used: 1. Via the PDG graphical utility PDG can be downloaded from www.renesas.com/pdg. The directions for use of the PDG utility are given in the PDG manual. 2. Or added to a project by the user and used stand-alone. To add the driver library to your project’s build environment, you need to a) b) c) d) 1.3.1. Unzip the RPDL distribution.
RX62N Group, RX621 Group 1. Introduction Select the device package and endian option by pressing a number, and then press Enter. Type the full path to the folder where you wish RPDL to be copied to, and then press Enter. The utility will create a folder in the location that you specified and copy the files into the new folder. R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 1. Introduction Press any key to close the window. R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 1.3.3. 1. Introduction Include the new directory Use the key sequence Alt, B, R to open the "RX Standard Toolchain" window. Select the C/C++ tab. Use the key sequence S, I to show the included file directories. Click on the "Add…" button. In the "Add include file directory" window, enter the details as shown: Click on "OK" to close the window. Click on the "Add…" button. In the "Add include file directory" window, enter the details as shown: Click on "OK" to close the window.
RX62N Group, RX621 Group 1.3.4. 1. Introduction Include the new source files Use the key sequence Alt, P, A to open the "Add files to project ‘’" window. Double click on the RPDL folder. From the "Files of type" drop-down list, select "C source file (*.C)". Use the key sequence Ctrl-A to select all the Interrupt handler files, as shown below. Click on "Add". Click on "OK" to return to the main HEW window.
RX62N Group, RX621 Group 1.3.5. 1. Introduction Avoid conflicts with standard project files. If the files ‘intprg.c’ or ‘vecttbl.c’ are included in the project, remove or exclude them. 1) Removal Use the key sequence Alt, P, R to open the "Remove Project Files" window. Select the files and click on Remove. R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 2) 1. Introduction Exclusion Select the two files and use the key sequence Alt, B, I to exclude them. Figure 1-3: intprg.c and vecttbl.c have been excluded R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 1.3.6. 1. Introduction Add the library file path The library file is added to the list used by the linker application. Use the key sequence Alt, B, R to open the "RX Standard Toolchain" window. Select the Link/Library tab. From the "Show entries for :" drop-down menu, select "Library files". Click on the "Add…" button. In the "Add library file" window, enter the details as shown: Click on "OK" to close the window. Click on "OK" to return to the main HEW window.
RX62N Group, RX621 Group 1.3.7. 1. Introduction Set the build options. Use the key sequence Alt, B, R to open the "RX Standard Toolchain" window. In this section, only options which you must change from the default settings are described. If you add RPDL in an existing project see 1.2 Compiler options when you use this product. Select the C/C++ tab. Use the key sequence Y, O, O to show the optimisation options. Ensure that the "Inter-module optimization" option is enabled and set "Optimize level" to 2.
RX62N Group, RX621 Group 1. Introduction Select the Link/Library tab. Use the key sequence Y, O, O to show the optimisation options. If the "Eliminate dead code" option is not enabled, from the Optimize drop-down list select Custom and enable the option. R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 1. Introduction 1.3.8. Add the "L" section Use the key sequence Alt-Y, S to show the section configuration options. Click the "Edit" button and ensure that an "L" section is included in the list. If it is not, add it below the "C" section as shown. Click on "OK" to close the window. Click on "OK" to return to the main HEW window. 1.3.9. Build the project No further configuration should be required. Simply build the project. R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 1. Introduction 1.3.10. Using the library with debug information RPDL library with debug information should be chosen, in order to step in the RPDL source code for debugging. Unzip the RPDL source "c:\my_project_folder"). zip file (e.g. "RPDL_RX62N_CS.x.xx_source.zip") into a folder (e.g. Set a breakpoint at the RPDL API to be debugged. When the program break at the RPDL API, press "F11" key to step in the function.
RX62N Group, RX621 Group 1. Introduction 1.3.11. Header file inclusion The RPDL folder contains a header file, iodefine_RPDL.h. This file is included by the RPDL source files and will also be included by any user-generated files that call RPDL functions. The main HEW project folder may contain the header file iodefine.h. This file is normally used if access to the I/O registers in the MCU is required. For any user-generated files that call RPDL functions, there is no need to include this file iodefine.h.
RX62N Group, RX621 Group 1. Introduction 1.4. Document structure The drivers are summarised in section 2 and explained in detail in section 4. Section 5 provides usage examples. Section 6 provides details which are specific to the RX CPU. R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 1. Introduction 1.5.
RX62N Group, RX621 Group 2. Driver 2. Driver 2.1. Overview This library provides a set of peripheral function control programs (peripheral drivers) for Renesas microcontrollers and allows the peripheral driver to be built into a user program. 2.2. Control Functions summary This library has the following control functions available as peripheral drivers. (1) Clock Generation Circuit These driver functions are used to configure the multiple internal clock signals.
RX62N Group, RX621 Group 2. Driver These driver functions are used for configuring and controlling the timers. (16) Compare Match Timer These driver functions are used for configuring and controlling the timers. (17) Real-time Clock These driver functions are used for configuring and controlling the real-time clock timer. (18) Watchdog Timer These driver functions are used for configuring and controlling the timer.
RX62N Group, RX621 Group 2. Driver 2.3. Clock Generation Circuit Driver The driver functions support the control of the internal clock generator, providing the following operations. 1. Configuration of the multiple clock outputs for system, peripheral and external bus operation. 2. Controlling the clock generator operation. 3. Reading the Clock generator status flags.
RX62N Group, RX621 Group 3. Types and definitions 2.4. Interrupt Control Driver The driver functions support the use of the interrupt controller, providing the following operations. 1. Configuration an external interrupt pin for use. 2. Enabling use of the software interrupt. 3. Assigning an interrupt to be processed using the Fast Interrupt route. 4. Assigning handlers for the fixed exception interrupts. 5. Controlling an external interrupt input. 6. Reading the status of an external interrupt. 7.
RX62N Group, RX621 Group 3. Types and definitions 2.5. I/O Port Driver The driver functions support the use of the I/O port pins, providing the following operations. 1. Configuration for use. 2. Reading the pin or port configuration. 3. Modifying the pin or port configuration. 4. Reading a pin or 8-bit port value. 5. Writing to a pin or 8-bit port. 6. Comparing a pin or 8-bit port with a supplied value. 7. Modifying a pin or 8-bit port using a logical operation. 8.
RX62N Group, RX621 Group 3. Types and definitions 2.6. Port Function Control Driver The driver functions support access to the Port Function Control (PFC) registers which select the mode of operation for some I/O pins. The other driver functions modify the PFC registers automatically. For peripherals that are not supported by the driver library, these functions support: 1. Reading from a PFC register. 2. Writing to a PFC register. 3. Modifying a PFC register R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 3. Types and definitions 2.7. MCU Operation Driver The driver functions support access to the registers which select the mode of operation for the microcontroller. These functions support: 1. Controlling the on-chip ROM and RAM. 2. Reading the MCU status flags. R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 3. Types and definitions 2.8. Low Power Consumption Driver The driver functions support access to the registers which select the lower power modes of operation for the microcontroller. These functions support: 1. Configuring the state while in standby mode, and the activity that can be used to resume operation. 2. Selecting one of the low-power modes. 3. Writing data to the backup memory area. 4. Reading data from the backup memory area. 5.
RX62N Group, RX621 Group 3. Types and definitions 2.9. Voltage Detection Circuit Driver The driver function supports access to the registers which control the voltage detection circuit. This function supports: 1. Configuring the response to the supply voltage dropping below either voltage threshold. R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 2.10. 3. Types and definitions Bus Controller Driver The driver functions support the control of the external bus, providing the following operations. 1. Configuration of the controller. 2. Configuration of the eight address space areas. 3. Configuration of the SDRAM address space area. 4. Disabling an area that is not required. 5. Controlling the bus controller. 6. Reading the status of the controller. R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 2.11. 3. Types and definitions DMA Controller Driver The driver functions support the control of the Direct Memory Access (DMA) controller, providing the following operations. 1. Configuration for use, including • Access to all control bits. • Automatic interrupt control 2. Disabling DMA channels that are no longer required and enabling low-power mode. 3. Control of a channel. 4. Reading the status and operation registers of a channel. R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 2.12. 3. Types and definitions External DMA Controller Driver The driver functions support the control of the external bus Direct Memory Access controller (EXDMAC), providing the following operations. 1. Configuration for use, including • Access to all control bits. • Automatic interrupt control 2. Disabling EXDMAC channels that are no longer required and enabling low-power mode. 3. Control of a channel. 4. Reading the status and operation registers of a channel.
RX62N Group, RX621 Group 2.13. 3. Types and definitions Data Transfer Controller Driver The driver functions support the control of the Data Transfer Controller, providing the following operations. 1. Setting the central options. 2. Configuration for use, including support for chain transfers. 3. Disabling the controller. 4. Starting or stopping the controller. 5. Reading the status flags and data transfer registers. R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 2.14. 3. Types and definitions Multi-Function Timer Pulse Unit Driver The driver functions support the use of the twelve 16-bit timers, providing the following operations. 1. Selection of the MTU pins for use. 2. Configuration for use, including • Access to all control bits. • Automatic interrupt control • Automatic I/O pin configuration 3. Disabling channels that are no longer required and enabling low-power mode. 4. Control of a timer channel. 5. Control of a timer unit. 6.
RX62N Group, RX621 Group 2.15. 3. Types and definitions Port Output Enable Driver The driver functions support the use of the Port Output module, providing the following operations. 1. Configuring the pins for use. 2. Configuring the interrupts and callback functions. 3. Run-time control of outputs, interrupts and flags. 4. Checking the module status. R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 2.16. 3. Types and definitions Programmable Pulse Generator Driver The driver functions support the use of the pulse generator, providing the following operations. 1. Configuring the generator for use. 2. Disabling groups of outputs that are no longer required. 3. Control of the generator during run-time. R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 2.17. 3. Types and definitions 8-bit Timer Driver The driver functions support the use of the four 8-bit timers, providing the following operations. 1. Selection of the TMR pins for use. 2. Configuring a channel for use, using register values which have been determined elsewhere. 3. Configuring two channels as a 16-bit pair, using register values which have been determined elsewhere. 4.
RX62N Group, RX621 Group 2.18. 3. Types and definitions Compare Match Timer Driver The driver functions support the use of the two 16-bit timers, providing the following operations. 1. Configuration for use, including • • • Automatic clock setting using frequency or period as an input. Manual clock setting using register values as inputs. Automatic interrupt control 2. Configuration for use as a one-shot timer. 3. Disabling channels that are no longer required and enabling low-power mode. 4.
RX62N Group, RX621 Group 2.19. 3. Types and definitions Real-time Clock Driver The driver functions support the use of the real-time clock, providing the following operations. 1. Configuring the clock for use, including • • • Alarm configuration. Optional day-of-week calculation Automatic alarm and periodic interrupt control 2. Control of the clock, including • • Changing the alarm settings. Changing the current date or time. 3. Reading the clock status flags and current time and date.
RX62N Group, RX621 Group 2.20. 3. Types and definitions Watchdog Timer Driver The driver functions support the use of the watchdog timer, providing the following operations. 1. Configuring the timer for use, including • • • • • Clock divider setting. Internal timer mode Watchdog timer mode MCU reset generation while in watchdog timer mode Automatic interrupt control 2. Control of the timer, including • • Stopping the timer Counter refresh to prevent overflow 3.
RX62N Group, RX621 Group 2.21. 3. Types and definitions Independent Watchdog Timer Driver The driver functions support the use of the independent watchdog timer, providing the following operations. 1. Configuring the timer for use. 2. Refreshing the timer to prevent the reset operation. 3. Reading the timer status and counter register. R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 2.22. 3. Types and definitions Serial Communication Interface Driver The driver functions support the use of the six serial communication channels (SCI0~SCI3, SCI5~SCI6), providing the following operations. 1. Selection of the SCI pins for use. 2. Configuration for use, including • • • Automatic baud rate clock calculations Automatic interrupt control Automatic I/O pin configuration 3. Disabling channels that are no longer required and enabling low-power mode. 4.
RX62N Group, RX621 Group 2.23. 3. Types and definitions CRC Calculator Driver The driver functions support the CRC calculator, providing the following operations. 1. Configuration for use, including • • • Polynomial selection. Bit order selection. Preparation for a new calculation. 2. Disabling the calculator and enabling low-power mode. 3. Writing data to be used for the calculation. 4. Reading the calculation result. R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 2.24. 3. Types and definitions I²C Bus Interface Driver The driver functions support the use of the two I²C modules, providing the following operations. 1. Configuration for use, including • • • Automatic clock setting using transfer rate as an input. Automatic interrupt control Automatic I/O pin configuration 2. Disabling modules that are no longer required and enabling low-power mode. 3. Transmitting data in Master mode. 4. Receiving data in Master mode. 5.
RX62N Group, RX621 Group 2.25. 3. Types and definitions Serial Peripheral Interface Driver The driver functions support the use of the two SPI channels, providing the following operations. 1. Configuration for use, including • • Automatic clock setting using transfer rate as an input. Automatic I/O pin configuration 2. Disabling channels that are no longer required and enabling low-power mode. 3. Configuration of command sequence settings. 4.
RX62N Group, RX621 Group 2.26. 3. Types and definitions 12-bit Analog to Digital Converter Driver The driver functions support the use of the 12-bit ADC unit, providing the following operations. 1. Configuration for use, including • • • Clock divider setting. Automatic interrupt control Automatic I/O pin configuration 2. Disabling the unit when no longer required and enabling low-power mode. 3. Control of one or more units, including • CPU sleep option 4.
RX62N Group, RX621 Group 2.27. 3. Types and definitions 10-bit Analog to Digital Converter Driver The driver functions support the use of the two ADC units, providing the following operations. 1. Configuration for use, including • • • Automatic clock setting using sampling time as an input. Automatic interrupt control Automatic I/O pin configuration 2. Disabling units that are no longer required and enabling low-power mode. 3. Control of one or more units, including • CPU sleep option 4.
RX62N Group, RX621 Group 2.28. 3. Types and definitions 10-bit Digital to Analog Converter Driver The driver functions support the use of the DAC module, providing the following operations. 1. Configuring a channel for use, including data alignment 2. Disabling channels that are no longer required and enabling low-power mode. 3. Writing data to a channel. R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 4. Library Reference 3. Types and definitions 3.1. Data types This section describes the data types used in this library. For details about the setting values, refer to the section "4.2 Description of Each API". The header files stdint.h and stdbool.h are included with the Renesas RX compiler. Table 1: Data types Type bool float uint8_t uint16_t int32_t uint32_t 3.2. 3.2.1. Defined in stdbool.h C stdint.
RX62N Group, RX621 Group 4. Library Reference 4. Library Reference 4.1. API List by Peripheral Function Table 4.1 lists the Renesas Embedded APIs by peripheral function. Table 4.
RX62N Group, RX621 Group Multi-function Timer pulse unit Port Output Enable Programmable Pulse Generator 8-bit Timer Compare Match Timer Real-time Clock Watchdog Timer Independent Watchdog Timer Serial Communication Interface CRC calculator I²C bus interface 1 2 3 4 5 6 7 1 2 3 4 1 2 3 1 2 3 4 5 6 7 8 9 10 11 1 2 3 4 5 1 2 3 1 2 3 1 2 3 1 2 3 4 5 6 7 1 2 3 4 1 2 3 4 5 6 7 8 9 R20UT0084EE0112 Rev.1.12 July. 16, 2014 4.
RX62N Group, RX621 Group Serial Peripheral Interface 12-bit Analog to Digital converter 10-bit Analog to Digital converter 10-bit Digital to Analog converter 1 2 3 4 5 6 1 2 3 4 1 2 3 4 1 2 3 R20UT0084EE0112 Rev.1.12 July. 16, 2014 4.
RX62N Group, RX621 Group 4. Library Reference 4.2. Description of Each API This section describes each API and explains how to use them, showing a program example for each. The description of each API is divided into the following items. Synopsis Summarises processing by the API function. Prototype The function format and a brief explanation of the arguments. Description Explains how to use the API function and shows assignable parameters separating each argument with [argument].
RX62N Group, RX621 Group 4.2.1. 1) 4. Library Reference Clock Generation Circuit R_CGC_Set Synopsis Configure the clock generation circuit. Prototype bool R_CGC_Set( uint32_t data1, uint32_t data2, uint32_t data3, uint32_t data4, uint16_t data5 ); Description // Input frequency // System clock frequency // Peripheral module clock frequency // External bus clock frequency // Configuration options Set the clock output frequencies and options.
RX62N Group, RX621 Group Remarks • • • 4. Library Reference This function must be called before configuring clock-dependent modules. This function modifies the BCLK and SDCLK pins for input or output. The maximum output frequency allowed on the BCLK pin is 25 MHz. Program example /* RPDL definitions */ #include "r_pdl_cgc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" void func(void) { /* Configure operation using a 12.
RX62N Group, RX621 Group 2) 4. Library Reference R_CGC_Control Synopsis Modify the clock generation circuit operation. Prototype bool R_CGC_Control( uint16_t data // Control options ); Description Modify the clock control registers. [data] Control options. If multiple selections are required, use "|" to separate each selection.
RX62N Group, RX621 Group 3) 4. Library Reference R_CGC_GetStatus Synopsis Configure the clock generation circuit. Prototype bool R_CGC_GetStatus( uint8_t * data // Pointer to the variable where the status value shall be stored. ); Description Read the clock status register. [data] The status flags shall be stored in the format below. b7 – b1 - Return value Category References Remarks b0 0: The main clock oscillator is operating normally. 1: The main clock oscillator has stopped. True.
RX62N Group, RX621 Group 4.2.2. 1) 4. Library Reference Interrupt Control Unit R_INTC_CreateExtInterrupt Synopsis Configure an external interrupt pin. Prototype bool R_INTC_CreateExtInterrupt( uint8_t data1, // Pin selection uint32_t data2, // Configuration void * func // Callback function uint8_t data3 // Interrupt priority level ); Description Sets the specified external interrupt. [data1] Choose the interrupt pin to be configured.
RX62N Group, RX621 Group Category Interrupt control Reference None. Remarks 4. Library Reference • The selected interrupt pin is enabled automatically. • Port Function Control registers PF8IRQ or PF9IRQ are modified to select the A or B IRQn pin. For smaller device packages, some A or B options are removed. For the 85-pin package, IRQ5, IRQ6 and IRQ7 are not available. • The appropriate I/O port ICR and DDR registers are modified. • Please see the notes on callback function use in §6.
RX62N Group, RX621 Group 2) 4. Library Reference R_INTC_CreateSoftwareInterrupt Synopsis Enable use of the software interrupt. Prototype bool R_INTC_CreateSoftwareInterrupt( uint8_t data1, // Configuration void * func, // Callback function uint8_t data2 // Interrupt priority level ); Description Configure and enable the software interrupt. [data1] Choose the pin settings. The default setting is shown in bold. • DTC trigger control.
RX62N Group, RX621 Group 3) 4. Library Reference R_INTC_CreateFastInterrupt Synopsis Enable faster interrupt processing for one interrupt. Prototype bool R_INTC_CreateFastInterrupt( uint8_t data // The interrupt to be selected ); Description (1/3) [data] Choose the interrupt vector to be processed using the fast interrupt process.
RX62N Group, RX621 Group Description (2/3) PDL_INTC_VECTOR_ADI12_0 PDL_INTC_VECTOR_TGIA0 PDL_INTC_VECTOR_TGIB0 PDL_INTC_VECTOR_TGIC0 PDL_INTC_VECTOR_TGID0 PDL_INTC_VECTOR_TCIV0 PDL_INTC_VECTOR_TGIE0 PDL_INTC_VECTOR_TGIF0 PDL_INTC_VECTOR_TGIA1 PDL_INTC_VECTOR_TGIB1 PDL_INTC_VECTOR_TCIV1 PDL_INTC_VECTOR_TCIU1 PDL_INTC_VECTOR_TGIA2 PDL_INTC_VECTOR_TGIB2 PDL_INTC_VECTOR_TCIV2 PDL_INTC_VECTOR_TCIU2 PDL_INTC_VECTOR_TGIA3 PDL_INTC_VECTOR_TGIB3 PDL_INTC_VECTOR_TGIC3 PDL_INTC_VECTOR_TGID3 PDL_INTC_VECTOR_TCIV3 PDL_
RX62N Group, RX621 Group Description (3/3) Return value Category PDL_INTC_VECTOR_CMIA1 PDL_INTC_VECTOR_CMIB1 PDL_INTC_VECTOR_OVI1 PDL_INTC_VECTOR_CMIA2 PDL_INTC_VECTOR_CMIB2 PDL_INTC_VECTOR_OVI2 PDL_INTC_VECTOR_CMIA3 PDL_INTC_VECTOR_CMIB3 PDL_INTC_VECTOR_OVI3 PDL_INTC_VECTOR_DMAC0I PDL_INTC_VECTOR_DMAC1I PDL_INTC_VECTOR_DMAC2I PDL_INTC_VECTOR_DMAC3I PDL_INTC_VECTOR_EXDMAC0I PDL_INTC_VECTOR_EXDMAC1I PDL_INTC_VECTOR_ERI0 PDL_INTC_VECTOR_RXI0 PDL_INTC_VECTOR_TXI0 PDL_INTC_VECTOR_TEI0 PDL_INTC_VECTOR_ERI1 PDL
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_intc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" void func( void ) { /* Assign the fast interrupt to the handler for pin IRQ3 */ R_INTC_CreateFastInterrupt( PDL_INTC_VECTOR_IRQ3 ); } /* Remember to edit r_pdl_user_definitions.h (see remark 2) */ R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 4) 4. Library Reference R_INTC_CreateExceptionHandlers Synopsis Assign handlers for the fixed-vector interrupts. Prototype bool R_INTC_CreateExceptionHandlers( void * func1, // Callback function void * func2, // Callback function void * func3, // Callback function void * func4 // Callback function ); Description Register the user functions to be called by the fixed-vector and software interrupts.
RX62N Group, RX621 Group 5) 4. Library Reference R_INTC_ControlExtInterrupt Synopsis External interrupt control. Prototype bool R_INTC_ControlExtInterrupt( uint8_t data1, // Pin selection uint32_t data2 // Control ); Description Modifies the specified external interrupt. [data1] Choose the interrupt pin to be controlled. PDL_INTC_IRQn (n = 0 to 15) or IRQn interrupt pin or PDL_INTC_NMI NMI interrupt pin [data2] Select the controls.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_intc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" void func( void ) { /* Disable the IRQ1 interrupt pin and clear the flag */ R_INTC_ControlExtInterrupt( PDL_INTC_IRQ1, PDL_INTC_DISABLE | PDL_INTC_CLEAR_IR_FLAG ); } R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 6) 4. Library Reference R_INTC_GetExtInterruptStatus Synopsis Read the external interrupt status. Prototype bool R_INTC_GetExtInterruptStatus( uint8_t data1, // Pin selection uint8_t * data2 // A pointer to the buffer where the status data shall be stored. ); Description Acquire the status for the specified external interrupt. [data1] Choose the interrupt pin to be checked.
RX62N Group, RX621 Group 4. Library Reference The INTC Read, Write and Modify functions use one of the following register definitions.
RX62N Group, RX621 Group 4.
RX62N Group, RX621 Group PDL_INTC_REG_IPR_ICU_IRQ11 PDL_INTC_REG_IPR_ICU_IRQ12 PDL_INTC_REG_IPR_ICU_IRQ13 PDL_INTC_REG_IPR_ICU_IRQ14 PDL_INTC_REG_IPR_ICU_IRQ15 PDL_INTC_REG_IPR_USB_USBR0 PDL_INTC_REG_IPR_USB_USBR1 PDL_INTC_REG_IPR_RTC_ALM PDL_INTC_REG_IPR_WDT_WOVI PDL_INTC_REG_IPR_AD0_ADI PDL_INTC_REG_IPR_AD1_ADI PDL_INTC_REG_IPR_S12AD_ADI PDL_INTC_REG_IPR_MTU0_TGIA PDL_INTC_REG_IPR_MTU0_TGIB PDL_INTC_REG_IPR_MTU0_TGIC PDL_INTC_REG_IPR_MTU0_TGID PDL_INTC_REG_IPR_MTU0_TCIV PDL_INTC_REG_IPR_MTU0_TGIE PDL_INTC
RX62N Group, RX621 Group DTCER register definitions PDL_INTC_REG_DTCER_ICU_SWINT PDL_INTC_REG_DTCER_CMT0_CMI PDL_INTC_REG_DTCER_CMT1_CMI PDL_INTC_REG_DTCER_CMT2_CMI PDL_INTC_REG_DTCER_CMT3_CMI PDL_INTC_REG_DTCER_USB0_D0FIFO PDL_INTC_REG_DTCER_USB0_D1FIFO PDL_INTC_REG_DTCER_USB1_D0FIFO PDL_INTC_REG_DTCER_USB1_D1FIFO PDL_INTC_REG_DTCER_SPI0_SPRI PDL_INTC_REG_DTCER_SPI0_SPTI PDL_INTC_REG_DTCER_SPI1_SPRI PDL_INTC_REG_DTCER_SPI1_SPTI PDL_INTC_REG_DTCER_ICU_IRQ0 PDL_INTC_REG_DTCER_ICU_IRQ1 PDL_INTC_REG_DTCER_ICU_
RX62N Group, RX621 Group 7) 4. Library Reference R_INTC_Read Synopsis Read an interrupt register. Prototype bool R_INTC_Read( uint16_t data1, uint8_t * data2 ); Description // Register selection // Data storage location Read an interrupt register and store the value. [data1] • The register to be read.
RX62N Group, RX621 Group 8) 4. Library Reference R_INTC_Write Synopsis Update an interrupt register. Prototype bool R_INTC_Write( uint16_t data1, uint8_t data2 ); Description // Register selection // Register value Write the new value to an interrupt register. [data1] • The register to be updated.
RX62N Group, RX621 Group 9) 4. Library Reference R_INTC_Modify Synopsis Modify an interrupt register. Prototype bool R_INTC_Modify( uint16_t data1, // Register selection uint8_t data2, // Logical operation uint8_t data3 // Modification value ); Description Update the value in an interrupt register. [data1] • The register to be updated.
RX62N Group, RX621 Group 4.2.3. 4. Library Reference I/O Port I/O Port functions may operate on a complete port, or on individual port pins. The available definitions are listed below.
RX62N Group, RX621 Group 4.
RX62N Group, RX621 Group 1) 4. Library Reference R_IO_PORT_Set Synopsis Configure an I/O port. Prototype bool R_IO_PORT_Set( uint16_t data1, // Port pin selection uint8_t data2 // Configuration ); Description Set the operating conditions for I/O port pins. [data1] Select the port pins to be configured (from §4.2.3). Do not use any whole-port definitions. Multiple pins on the same port may be specified, using "|" to separate each pin. [data2] Choose the pin settings.
RX62N Group, RX621 Group 2) 4. Library Reference R_IO_PORT_ReadControl Synopsis Read an I/O port’s control registers. Prototype bool R_IO_PORT_ReadControl( uint16_t data1, // Port or port pin selection uint8_t data2, // Control register selection uint8_t * data3 // Data storage location ); Description Read an I/O port pin control setting. [data1] Use either one of the following definition values (from §4.2.3). • One port definition or • One port pin definition.
RX62N Group, RX621 Group 3) 4. Library Reference R_IO_PORT_ModifyControl Synopsis Modify an I/O port’s control registers. Prototype bool R_IO_PORT_ModifyControl( uint16_t data1, // Port or port pin selection uint8_t data2, // Control register and logical operation selection uint8_t data3 // Modification value ); Description Modifying the operation of an I/O port or I/O port pin. [data1] Use either one of the following definition values (from §4.2.3).
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_io_port.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" void func(void) { /* Set the lower 4 bits on port P1 to output */ R_IO_PORT_ModifyControl( PDL_IO_PORT_1, PDL_IO_PORT_DIRECTION | PDL_IO_PORT_OR, 0x0F ); /* Enable the pull-up on pin PA3 */ R_IO_PORT_ModifyControl( PDL_IO_PORT_A_3, PDL_IO_PORT_PULL_UP | PDL_IO_PORT_OR, 1 ); } R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 4) 4. Library Reference R_IO_PORT_Read Synopsis Read data from an I/O port. Prototype bool R_IO_PORT_Read( uint16_t data1, // Port or port pin selection uint8_t * data2 // Pointer to the variable in which the value shall be stored. ); Description Gets the value of an I/O port or I/O port pin. [data1] Use either one of the following definition values (from §4.2.3). • One port definition or • One port pin definition.
RX62N Group, RX621 Group 5) 4. Library Reference R_IO_PORT_Write Synopsis Write data to an I/O port. Prototype bool R_IO_PORT_Write( uint16_t data1, // Port or port pin selection uint8_t data2 // The data to be written to the I/O port or port pin. ); Description Write data to an I/O port or I/O port pin. [data1] Use either one of the following definition values (from §4.2.3). • One port definition or • One port pin definition.
RX62N Group, RX621 Group 6) 4. Library Reference R_IO_PORT_Compare Synopsis Check the pin states on an I/O port. Prototype bool R_IO_PORT_Compare( uint16_t data1, // Input port or port pin selection uint8_t data2, // Comparison value void * func // Function pointer ); Description Read the input state of an I/O port or I/O port pin and call a function if a match occurs. [data1] Use either one of the following definition values (from §4.2.3): • One port definition or • One port pin definition.
RX62N Group, RX621 Group 7) 4. Library Reference R_IO_PORT_Modify Synopsis Modify the pin states on an I/O port. Prototype bool R_IO_PORT_Modify( uint16_t data1, // Output port or port pin selection uint8_t data2, // Logical operation uint8_t data3 // Modification value ); Description Read the output state of an I/O port or I/O port pin, modify the result and write it back to the port. [data1] Use either one of the following definition values (from §4.2.3).
RX62N Group, RX621 Group 8) 4. Library Reference R_IO_PORT_Wait Synopsis Wait for a match on an I/O port. Prototype bool R_IO_PORT_Wait( uint16_t data1, // Output port or port pin selection uint8_t data2 // Comparison value ); Description Loop until an I/O port or I/O port pin matches the comparison value. [data1] Use either one of the following definition values (from §4.2.3). • One port definition or • One port pin definition.
RX62N Group, RX621 Group 4.2.4. 4. Library Reference Port Function Control Each I/O Port function can operate on a complete port, or on individual port pins. The definitions available to functions are listed below.
RX62N Group, RX621 Group 1) 4. Library Reference R_PFC_Read Synopsis Read a PFC register. Prototype bool R_PFC_Read( uint8_t data1, uint8_t * data2 ); Description // PFC register selection // Pointer to the variable where the PFC register’s value shall be stored. Get the value of a PFC register. [data1] One of the definition values from §4.2.4. [data2] The value read from the register. Return value Category References Remarks True if a valid register is specified; otherwise false.
RX62N Group, RX621 Group 2) 4. Library Reference R_PFC_Write Synopsis Write to a PFC register. Prototype bool R_PFC_Write( uint8_t data1, // PFC register selection uint8_t data2 // Data to be written to the PFC register ); Description Write the value to a PFC register. [data1] One of the definition values from §4.2.4. [data2] The value to be written to the register. Return value Category References Remarks True if a valid register is specified; otherwise false. PFC registers None.
RX62N Group, RX621 Group 3) 4. Library Reference R_PFC_Modify Synopsis Modify a PFC register. Prototype bool R_PFC_Modify( uint8_t data1, // PFC register selection uint8_t data2, // Logical operation uint8_t data3 // Modification value ); Description Write the value to a PFC register. [data1] One of the definition values from §4.2.4. [data2] • The logical operation to be applied to the register contents. PDL_PFC_AND or PDL_PFC_OR or Select between AND (&), OR (|) or Exclusive-OR (^).
RX62N Group, RX621 Group 4.2.5. MCU operation 1) R_MCU_Control 4. Library Reference Synopsis Control the operation of the MCU. Prototype bool R_MCU_Control( uint8_t data // Control options ); Description Modify the MCU control registers. [data] Select the operation states. If multiple selections are required, use "|" to separate each selection. Specify PDL_NO_DATA to use the defaults.
RX62N Group, RX621 Group 2) 4. Library Reference R_MCU_GetStatus Synopsis Read the MCU status. Prototype bool R_MCU_GetStatus( uint16_t * data // Pointer to the variable where the status value shall be stored. ); Description Read the status registers for the MCU. [data] The status flags shall be stored in the format below.
RX62N Group, RX621 Group 4.2.6. 1) 4. Library Reference Low Power Consumption R_LPC_Create Synopsis Configure the MCU low power conditions. Prototype bool R_LPC_Create( uint32_t data1, // Configuration options uint32_t data2 // Waiting times ); Description (1/2) Load the registers that control module or CPU operation. [data1] Select the required settings. If multiple selections are required, use "|" to separate each selection. The default settings are shown in bold.
RX62N Group, RX621 Group Description (2/2) [data2] Select the waiting times. If multiple selections are required, use "|" to separate each selection. The default settings are shown in bold. Specify PDL_NO_DATA to use the defaults.
RX62N Group, RX621 Group 2) 4. Library Reference R_LPC_Control Synopsis Select a low power consumption mode. Prototype bool R_LPC_Control( uint16_t data // Mode selection ); Description Transition to one of the low power modes. [data] Control selection. All selections are optional. The default settings are shown in bold. If multiple selections are required, use "|" to separate each selection.
RX62N Group, RX621 Group 3) 4. Library Reference R_LPC_WriteBackup Synopsis Write to the Backup registers. Prototype bool R_LPC_WriteBackup( uint8_t * data1, // Data pointer uint8_t data2 // Data count ); Description Write data into the backup registers. [data1] The data to be written to the backup area. [data2] The number of bytes to be written to the backup area. Valid from 1 to 32. Return value Category References Remarks True if all parameters are valid; otherwise false. LPC None.
RX62N Group, RX621 Group 4) 4. Library Reference R_LPC_ReadBackup Synopsis Read from the Backup registers. Prototype bool R_LPC_ReadBackup( uint8_t * data1, // Data pointer uint8_t data2 // Data count ); Description Read data from the backup registers. [data1] The storage area for the data read from the backup area. [data2] The number of bytes to be read from the backup area. Valid from 1 to 32. Return value Category References Remarks True if all parameters are valid; otherwise false.
RX62N Group, RX621 Group 5) 4. Library Reference R_LPC_GetStatus Synopsis Read the status flags. Prototype bool R_LPC_GetStatus( uint16_t * data // Data pointer ); Description Read the Deep Standby Interrupt Flag and Reset Status. [data] The status flags shall be stored in the format below.
RX62N Group, RX621 Group 4.2.7. 1) 4. Library Reference Voltage Detection Circuit R_LVD_Control Synopsis Configure the voltage detection circuit. Prototype bool R_LVD_Control( uint8_t data // Configuration selection ); Description Set the voltage detection configuration. [data] Set the voltage detection operation.
RX62N Group, RX621 Group 4.2.8. Bus Controller 1) R_BSC_Create 4. Library Reference Synopsis Configure the external bus controller.
RX62N Group, RX621 Group Description (2/2) 4. Library Reference [data2] • Address output control. The signals are enabled by default. Specify PDL_NO_DATA for no change. PDL_BSC_A9_A0_DISABLE Disable the output of the A9 to A0 signals. PDL_BSC_A9_A4_DISABLE Disable the output of the A9 to A4 signals. PDL_BSC_A9_A8_DISABLE Disable the output of the A9 to A8 signals. PDL_BSC_A10_DISABLE Disable the output of the A10 signal. PDL_BSC_A11_DISABLE Disable the output of the A11 signal.
RX62N Group, RX621 Group Remarks 4. Library Reference • Multiple chip select signals can be output from one I/O pin. The following diagram shows the CSn pins for 176-pin packages. Please refer hardware manual for other pin packages.
RX62N Group, RX621 Group 2) 4. Library Reference R_BSC_CreateArea Synopsis Configure an external bus area.
RX62N Group, RX621 Group Description (2/2) 4. Library Reference [data5] The number of wait cycles used for second and subsequent accesses during a page read sequence (CSPRWAIT). Valid between 0 and 7. [data6] The number of wait cycles used for second and subsequent accesses during a page write sequence (CSPWWAIT). Valid between 0 and 7. [data7] The number of wait cycles for the first access during a normal or page read sequence (CSRWAIT). Valid between 0 and 31.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_bsc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" void func(void) { /* Configure CS2: 8-bit width, no wait cycles */ R_BSC_CreateArea(2, PDL_BSC_WIDTH_8, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 ); } R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 3) 4. Library Reference R_BSC_SDRAM_CreateArea Synopsis Configure the SDRAM area.
RX62N Group, RX621 Group Description (2/2) 4. Library Reference [data7] The value to be set to CL bits in SDRAM Timing Register (SDTR). Valid between 0x01 and 0x03. Setting of 0x00 or more than 0x03 is prohibited. [data8] The value to be set to WR bit in SDRAM Timing Register (SDTR). Valid between 0x00 and 0x01. [data9] The value to be set to RP bits in SDRAM Timing Register (SDTR). Valid between 0x00 and 0x07. [data10] The value to be set to RCD bits in SDRAM Timing Register (SDTR).
RX62N Group, RX621 Group 4) 4. Library Reference R_BSC_Destroy Synopsis Stop the External Bus Controller. Prototype bool R_BSC_Destroy( uint8_t data // Area selection ); Description Disable an external bus area. [data] Select the external bus area CSn (where n = 0 to 7) to be disabled. Return value True. Category Bus Controller Reference R_BSC_CreateArea Remarks • The bus error interrupt request will not be disabled by this function. Use R_BSC_Control to disable it.
RX62N Group, RX621 Group 5) 4. Library Reference R_BSC_Control Synopsis Modify the External Bus & SDRAM Controller operation. Prototype bool R_BSC_Control( uint16_t data ); Description // Control options Control the BSC & SDRAM operation [data] Control the BSC & SDRAM operation. Only one control operation is allowed at one time. Return value • Error clearing PDL_BSC_ERROR_CLEAR Clear the bus-error status registers.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_bsc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" void func(void) { /* Clear the bus error signals */ R_BSC_Control( PDL_BSC_ERROR_CLEAR ); } R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 6) 4. Library Reference R_BSC_GetStatus Synopsis Read the status registers of External Bus & SDRAM Controller. Prototype bool R_BSC_GetStatus( uint8_t * data1, // A pointer to the data1 storage location uint16_t * data2, // A pointer to the data2 storage location uint8_t * data3 // A pointer to the data3 storage location ); Description Read the status registers of Bus & SDRAM Controller [data1] The status flags shall be stored according to register BERSR1 format as below.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_bsc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" void func(void) { uint8_t status1, status3; uint16_t status2; /* Read the flags */ R_BSC_GetStatus( &status1, &status2, &status3 ); } R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 4.2.9. DMA Controller 1) R_DMAC_Create 4. Library Reference Synopsis Configure the DMA controller.
RX62N Group, RX621 Group Description (2/3) • Start trigger forwarding PDL_DMAC_TRIGGER_CLEAR or PDL_DMAC_TRIGGER_FORWARD 4. Library Reference When the DMAC transfer is complete, clear the DMAC activation trigger or pass it on to the CPU. • DTC trigger control PDL_DMAC_DTC_TRIGGER_DISABLE or PDL_DMAC_DTC_TRIGGER_ENABLE Disable or enable activation of the DTC when an event specified in the "Interrupt generation" options occurs. [data3] Select one activation source for channel DMAn.
RX62N Group, RX621 Group Description (3/3) 4. Library Reference [data5] The destination start address. [data6] The number of transfers to take place. For normal mode: valid between 0 and 65535 (0 = free running mode). For repeat and block mode: valid between 0 and 1023 (0 = 1024 transfers). [data7] The repeat or block size for each transfer. For repeat mode: valid between 0 and 1023 (0 = 1024 units). For block mode: valid between 1 and 1023. Ignored in normal mode. [data8] The address offset value.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_dmac.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 2) 4. Library Reference R_DMAC_Destroy Synopsis Disable the DMA controller. Prototype bool R_DMAC_Destroy( uint8_t data // Channel number ); Description Shutdown the DMAC module. [data] The channel number n (where n = 0 to 3). Return value True if the shutdown succeeded; otherwise false. Category DMA controller Reference R_DMAC_Create. Remarks • If all channels have been suspended, the DMAC module will be shut down.
RX62N Group, RX621 Group 3) 4. Library Reference R_DMAC_Control Synopsis Control the DMA controller.
RX62N Group, RX621 Group Description (2/2) 4. Library Reference [data7] The address offset value. The range is from +16,777,215 to -16,777,216. This value is ignored if the offset function is not selected. Specify PDL_NO_DATA if not required. [data8] The source address extended repeat value. The value can be any power of 2, from 21 to 227. Specify PDL_NO_DATA if not required. [data9] The destination address extended repeat value. The value can be any power of 2, from 21 to 227.
RX62N Group, RX621 Group 4) 4. Library Reference R_DMAC_GetStatus Synopsis Check the status of a DMA channel.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_dmac.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" void func(void) { uint8_t StatusValue; uint32_t SourceAddr; /* Read the status and current source address for channel 2 */ R_DMAC_GetStatus( 2, &StatusValue, &SourceAddr, PDL_NO_PTR, PDL_NO_PTR, PDL_NO_PTR ); } R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 4. Library Reference 4.2.10. External DMA Controller 1) R_EXDMAC_Create Synopsis Configure the EXDMA controller.
RX62N Group, RX621 Group Description (2/3) 4. Library Reference [data3] Configure the trigger and output options. Use "|" to separate each selection. The default settings are shown in bold. • Pin selection PDL_EXDMAC_PIN_A or PDL_EXDMAC_PIN_B or PDL_EXDMAC_PIN_C Select the -A, -B or -C pins for signals EDREQn and EDACKn.
RX62N Group, RX621 Group Description (3/3) 4. Library Reference [data10] The source address extended repeat value. The value can be any power of 2, from 21 to 227. Specify PDL_NO_DATA if the extended repeat function is not required for the source address. [data11] The destination address extended repeat value. The value can be any power of 2, from 21 to 227. Specify PDL_NO_DATA if the extended repeat function is not required for the destination address.
RX62N Group, RX621 Group 2) 4. Library Reference R_EXDMAC_Destroy Synopsis Disable the EXDMA controller. Prototype bool R_EXDMAC_Destroy( uint8_t data // Channel number ); Description Shutdown the EXDMAC module. [data] The channel number n (where n = 0 to 1). Return value True if the shutdown succeeded; otherwise false. Category EXDMA controller Reference R_EXDMAC_Create Remarks • If all channels have been suspended, the EXDMAC module will be shut down.
RX62N Group, RX621 Group 3) 4. Library Reference R_EXDMAC_Control Synopsis Control the EXDMA controller.
RX62N Group, RX621 Group Description (2/2) 4. Library Reference [data7] The address offset value. Specify PDL_NO_DATA if not required. [data8] The source address extended repeat value. Specify PDL_NO_DATA if not required. [data9] The destination address extended repeat value. Specify PDL_NO_DATA if not required. Return value True if all parameters are valid and exclusive; otherwise false.
RX62N Group, RX621 Group 4) 4. Library Reference R_EXDMAC_GetStatus Synopsis Check the status of an EXDMAC channel.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_exdmac.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" void func(void) { uint8_t StatusValue; uint32_t SourceAddr; uint32_t DestAddr ; /* Read the status and current source address for channel 1 */ R_EXDMAC_GetStatus( 1, &StatusValue, &SourceAddr, &DestAddr, PDL_NO_PTR, PDL_NO_PTR ); } R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 4. Library Reference 4.2.11. Data Transfer Controller 1) R_DTC_Set Synopsis Set the Data Transfer Controller options. Prototype bool R_DTC_Set ( uint8_t data1, uint32_t * data2 ); Description // Configuration options // Vector table base address Set the global options for the Data Transfer Controller. [data1] Configuration selections. If multiple selections are required, use "|" to separate each selection. The default settings are shown in bold.
RX62N Group, RX621 Group 2) 4. Library Reference R_DTC_Create Synopsis Configure the Data Transfer Controller for a transfer. Prototype bool R_DTC_Create( uint32_t data1, uint32_t * data2, void * data3, void * data4, uint16_t data5, uint8_t data6 ); Description (1/3) // Configuration selection // Transfer data start address // Source start address // Destination start address // Transfer count // Block size Configure DTC activation for one trigger source. [data1] Configuration selections.
RX62N Group, RX621 Group Description (2/3) PDL_DTC_TRIGGER_SPI0_RX or PDL_DTC_TRIGGER_SPI1_RX or PDL_DTC_TRIGGER_SPI0_TX or PDL_DTC_TRIGGER_SPI1_TX or PDL_DTC_TRIGGER_IRQ0 or PDL_DTC_TRIGGER_IRQ1 or PDL_DTC_TRIGGER_IRQ2 or PDL_DTC_TRIGGER_IRQ3 or PDL_DTC_TRIGGER_IRQ4 or PDL_DTC_TRIGGER_IRQ5 or PDL_DTC_TRIGGER_IRQ6 or PDL_DTC_TRIGGER_IRQ7 or PDL_DTC_TRIGGER_IRQ8 or PDL_DTC_TRIGGER_IRQ9 or PDL_DTC_TRIGGER_IRQ10 or PDL_DTC_TRIGGER_IRQ11 or PDL_DTC_TRIGGER_IRQ12 or PDL_DTC_TRIGGER_IRQ13 or PDL_DTC_TRIGGER_IRQ1
RX62N Group, RX621 Group Description (3/3) PDL_DTC_TRIGGER_CMIA0 or PDL_DTC_TRIGGER_CMIA1 or PDL_DTC_TRIGGER_CMIA2 or PDL_DTC_TRIGGER_CMIA3 or PDL_DTC_TRIGGER_CMIB0 or PDL_DTC_TRIGGER_CMIB1 or PDL_DTC_TRIGGER_CMIB2 or PDL_DTC_TRIGGER_CMIB3 or PDL_DTC_TRIGGER_DMACI0 or PDL_DTC_TRIGGER_DMACI1 or PDL_DTC_TRIGGER_DMACI2 or PDL_DTC_TRIGGER_DMACI3 or PDL_DTC_TRIGGER_EXDMACI0 or PDL_DTC_TRIGGER_EXDMACI1 or PDL_DTC_TRIGGER_RXI0 or PDL_DTC_TRIGGER_RXI1 or PDL_DTC_TRIGGER_RXI2 or PDL_DTC_TRIGGER_RXI3 or PDL_DTC_TRIG
RX62N Group, RX621 Group Remarks 4. Library Reference • If address increment or decrement is selected, the address changes according to the number of bytes (1, 2 or 4) in each transfer. • Before calling this function, call R_DTC_Set. • Call this function before configuring the peripherals that will be involved in the data transfer. • Call this function once for each peripheral that will trigger a transfer, and for each chained transfer.
RX62N Group, RX621 Group 3) 4. Library Reference R_DTC_Destroy Synopsis Disable the Data Transfer Controller. Prototype bool R_DTC_Destroy( void // No parameter is required ); Description Shutdown the Data Transfer Controller. Return value True. Category Data Transfer Controller Reference R_DTC_Control Remarks • This function will also shut down the DMAC. • Before calling this function, i.
RX62N Group, RX621 Group 4) 4. Library Reference R_DTC_Control Synopsis Control the Data Transfer Controller. Prototype bool R_DTC_Control ( uint32_t data1, uint32_t * data2, void * data3, void * data4, uint16_t data5, uint8_t data6 ); Description // Control options // Transfer data start address // Source start address // Destination start address // Transfer count // Block size Modify the operation of the Data Transfer Controller. [data1] Control the operation.
RX62N Group, RX621 Group Remarks 4. Library Reference • This function must be called in order to start the DTC (R_DTC_Create must be called at least once before starting the DTC). • Start the DTC before generating a transfer trigger. Program example /* RPDL definitions */ #include "r_pdl_dtc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 5) 4. Library Reference R_DTC_GetStatus Synopsis Check the status of the Data Transfer Controller.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_dtc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 4. Library Reference 4.2.12. Multi-Function Timer Pulse Unit 1) R_MTU2_Set Synopsis Configure the Multi-function Timer Pulse Units. Prototype bool R_MTU2_Set( uint16_t data ); Description // Configuration Set up the global MTU options. [data] Select the MTU I/O pin options. All settings are optional. Use "|" to separate each selection.
RX62N Group, RX621 Group 2) 4. Library Reference R_MTU2_Create Synopsis Configure an MTU channel.
RX62N Group, RX621 Group Description (2/8) 4. Library Reference • Synchronous mode. Valid for n = 0 to 4 or 6 to 10. PDL_MTU2_SYNC_DISABLE or Disable or enable synchronous presetting / clearing. PDL_MTU2_SYNC_ENABLE • DMAC / DTC event trigger control. Valid for n = 0 to 4 or 6 to 10 unless stated otherwise. PDL_MTU2_TGRA_DMAC_DTC_TRIGGER_DISABLE or TGRA compare match or input PDL_MTU2_TGRA_DMAC_TRIGGER_ENABLE or capture.
RX62N Group, RX621 Group Description (3/8) 4. Library Reference • Counter clock source selection. Valid for n = 5 or 11. PDL_MTU2_CLKU_PCLK_DIV_1 or PDL_MTU2_CLKU_PCLK_DIV_4 or Counter TCNTU is supplied by the internal clock PDL_MTU2_CLKU_PCLK_DIV_16 or signal PCLK ÷ 1, 4, 16 or 64. PDL_MTU2_CLKU_PCLK_DIV_64 or PDL_MTU2_CLKV_PCLK_DIV_1 or PDL_MTU2_CLKV_PCLK_DIV_4 or Counter TCNTV is supplied by the internal clock PDL_MTU2_CLKV_PCLK_DIV_16 or signal PCLK ÷ 1, 4, 16 or 64.
RX62N Group, RX621 Group Description (4/8) 4. Library Reference • Control ADC triggers. Valid for n = 4 or 10 in complementary PWM mode unless stated otherwise PDL_MTU2_ADC_TRIG_A_DOWN_DISABLE or Disable or enable ADC trigger TRGnAN PDL_MTU2_ADC_TRIG_A_DOWN_ENABLE requests during down-count operation. PDL_MTU2_ADC_TRIG_B_DOWN_DISABLE or Disable or enable ADC trigger TRGnBN PDL_MTU2_ADC_TRIG_B_DOWN_ENABLE requests during down-count operation.
RX62N Group, RX621 Group Description (5/8) 4. Library Reference [data6] Configure the operation for general registers TGRA and TGRB. Valid for n = 0 to 4 or 6 to 10. If multiple selections are required, use "|" to separate each selection. The default settings are shown in bold. Specify PDL_NO_DATA to use the defaults. • Input capture / output compare control for register TGRA PDL_MTU2_A_OC_DISABLED or MTIOCnA output disabled. PDL_MTU2_A_OC_LOW or MTIOCnA output low.
RX62N Group, RX621 Group Description (6/8) 4. Library Reference [data7] Configure the operation for general registers TGRC and TGRD. Valid for n = 0, 3, 4, 6, 9 and 10. If multiple selections are required, use "|" to separate each selection. The default settings are shown in bold. Specify PDL_NO_DATA to use the defaults. • Input capture / output compare control for register TGRC. PDL_MTU2_C_OC_DISABLED or MTIOCnC output disabled. PDL_MTU2_C_OC_LOW or MTIOCnC output low.
RX62N Group, RX621 Group Description (7/8) 4. Library Reference [data8] Configure the input capture / compare match control for general registers TGRU, TRGV and TGRW. Valid for n = 5 or 11. The default settings are shown in bold. Specify PDL_NO_DATA to use the defaults. • Input capture / compare match control for register TGRU. PDL_MTU2_U_CM or Compare match. PDL_MTU2_U_IC_RISING_EDGE or Input capture at MTICnU rising edge. PDL_MTU2_U_IC_FALLING_EDGE or Input capture at MTICnU falling edge.
RX62N Group, RX621 Group Description (8/8) 4. Library Reference [data14] For n = 0 or 6: The register TGRE value. For n = 5 or 11: The register TGRW value. Ignored for n = 1, 2, 3, 4, 7, 8, 9 or 10. [data15] For n = 0 or 6: The register TGRF value. For n = 4 or 10: The register TADCORA value. Ignored for n = 1, 2, 3, 5, 7, 8, 9 or 11. [data16] The register TADCORB value (ignored for n ≠ 4 or 10). [data17] The register TADCOBRA value (ignored for n ≠ 4 or 10).
RX62N Group, RX621 Group Return value True if all parameters are valid and exclusive; otherwise false. Category Multi-function Timer Pulse Unit Reference R_MTU2_Set, R_MTU2_ControlChannel, R_MTU2_ControlUnit Remarks 4. Library Reference • If an external clock input pin (MTCLKx) or I/O pin (MTIOCnx) is made active, this function will configure that pin for input or output and disable other functions on that pin. • The alternative pins are assigned using function R_MTU2_Set.
RX62N Group, RX621 Group 3) 4. Library Reference R_MTU2_Destroy Synopsis Disable a Multi-function Timer Pulse Unit. Prototype bool R_MTU2_Destroy( uint8_t data // Unit selection ); Description Shut down a timer pulse unit [data] The muti-function timer pulse unit n (where n = 0 or 1). Unit 0 comprises channels 0 to 5. Unit 1 comprises channels 6 to 11. Return value True if the unit selection is valid; otherwise false. Category Multi-function Timer Pulse Unit Reference None.
RX62N Group, RX621 Group 4) 4. Library Reference R_MTU2_ControlChannel Synopsis Control an MTU channel.
RX62N Group, RX621 Group Description (2/2) For n = 5 or 11. PDL_MTU2_REGISTER_COUNTER_U PDL_MTU2_REGISTER_COUNTER_V PDL_MTU2_REGISTER_COUNTER_W PDL_MTU2_REGISTER_TGRU PDL_MTU2_REGISTER_TGRV PDL_MTU2_REGISTER_TGRW 4. Library Reference Timer counter U register (TCNTU). Timer counter V register (TCNTV). Timer counter W register (TCNTW). General register U. General register V. General register W. [data4] For n = 0 to 4 or 6 to 10: The timer counter TCNT value. For n = 5 or 11: The timer counter TCNTU value.
RX62N Group, RX621 Group Remarks 4. Library Reference • Before calling this function, use R_MTU2_Create to configure the channel operation. • Either this function or R_MTU2_ControlUnit must be used to start the timers. • The Stop operation is executed at the start of this function. The Start operation is executed at the end. Therefore, both options can be selected together with other changes in one function call.
RX62N Group, RX621 Group 5) 4. Library Reference R_MTU2_ControlUnit Synopsis Control a Multi-function Timer Pulse Unit.
RX62N Group, RX621 Group Description (2/4) 4. Library Reference [data3] The output control settings to be modified. All settings are optional. If multiple selections are required, use "|" to separate each selection. • Output control. Select one option for each output.
RX62N Group, RX621 Group Description (3/4) 4. Library Reference [data4] The buffer control settings to be modified. All settings are optional. If multiple selections are required, use "|" to separate each selection. • Output level buffer control (applies only to reset-synchronised or complementary PWM modes). Set the output control to be transferred to the output: PDL_MTU2_OUT_BUFFER_P_PHASE_1_LOW or For n = 0: MTIOC3B. PDL_MTU2_OUT_BUFFER_P_PHASE_1_HIGH For n = 1: MTIOC9B.
RX62N Group, RX621 Group Description (4/4) 4. Library Reference [data6] General control settings. All settings are optional. If multiple selections are required, use "|" to separate each selection.
RX62N Group, RX621 Group Reference Remarks 4. Library Reference R_MTU2_ControlChannel • Either this function or R_MTU2_ControlChannel must be used to start the timers. • The Stop operation is executed at the start of this function. The Start operation is executed at the end. Therefore, both options can be selected together with other changes in one function call. • The register access enable operation is executed at the start of this function. The register access disable operation is executed at the end.
RX62N Group, RX621 Group 6) 4. Library Reference R_MTU2_ReadChannel Synopsis Read from MTU channel registers.
RX62N Group, RX621 Group Description (2/2) 4. Library Reference [data3] For n = 0 to 4 or 6 to 10: A pointer to where the TCNT register value shall be stored. For n = 5 or 11: A pointer to where the TCNTU register value shall be stored. Specify PDL_NO_PTR if it is not required. [data4] For n = 0 to 4 or 6 to 10: A pointer to where the TGRA register value shall be stored. For n = 5 or 11: A pointer to where the TCNTV register value shall be stored. Specify PDL_NO_PTR if it is not required.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_mtu2.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" uint8_t Flags; uint16_t General_A; uint16_t General_D; void func(void) { /* Read the status flags and registers of channel 3 */ R_MTU2_ReadChannel( 3, &Flags, PDL_NO_PTR, &General_A, PDL_NO_PTR, PDL_NO_PTR, &General_D, PDL_NO_PTR, PDL_NO_PTR ); } R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 7) 4. Library Reference R_MTU2_ReadUnit Synopsis Read from MTU registers. Prototype bool R_MTU2_ReadUnit( uint8_t data1, // Unit selection uint16_t * data2, // A pointer to the data storage location uint8_t * data3 // A pointer to the data storage location ); Description Read any of the timer units’s counter registers [data1] The unit number n (where n = 0 to 1). [data2] A pointer to where the Timer Subcounter register (TCNTS) value shall be stored.
RX62N Group, RX621 Group 4. Library Reference 4.2.13. Port Output Enable 1) R_POE_Set Synopsis Configure the Port Output Enable module. Prototype bool R_POE_Set( uint32_t data1, uint8_t data2, uint32_t data3 ); Description (1/2) // Input configuration selection // Input configuration selection // Output configuration selection Initialise the POE pins. [data1] Configure the input pin detection for pins POE0 to POE7. If multiple selections are required, use "|" to separate each selection.
RX62N Group, RX621 Group Description (2/2) 4. Library Reference [data3] Configure pin output control. If multiple selections are required, use "|" to separate each selection. All settings are optional. Specify PDL_NO_DATA if none are required. • High impedance request detection PDL_POE_HI_Z_REQ_8_ENABLE If a request is detected on pin POE8, place the MTU channel 0 I/O pins in the high impedance state.
RX62N Group, RX621 Group 2) 4. Library Reference R_POE_Create Synopsis Configure the Port Output Enable event handling. Prototype bool R_POE_Create( uint16_t data1, void * func1, void * func2, void * func3, void * func4, uint8_t data2 ); Description // Input configuration selection // Callback function // Callback function // Callback function // Callback function // Interrupt priority level Enable interrupts and register callback functions. [data1] Interrupt selection.
RX62N Group, RX621 Group Remarks 4. Library Reference • A callback function is executed by the interrupt processing function. This means that no other interrupt can be processed until the callback function has completed. • Use R_POE_GetStatus to determine the interrupt cause. Program example /* RPDL definitions */ #include "r_pdl_poe.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 3) 4. Library Reference R_POE_Control Synopsis Control the Port Output Enable module. Prototype bool R_POE_Control ( uint8_t data1, // Control options uint16_t data2, // Control options uint16_t data3 // Control options ); Description (1/2) Change the state of output pins, status flags and interrupt control. [data1] Manual high impedance control. If multiple selections are required, use "|" to separate each selection. All settings are optional.
RX62N Group, RX621 Group Description (2/2) 4. Library Reference [data3] Interrupt control. If multiple selections are required, use "|" to separate each selection. All settings are optional. Specify PDL_NO_DATA if no control is required.
RX62N Group, RX621 Group 4) 4. Library Reference R_POE_GetStatus Synopsis Check the status of the Port Output Enable module. Prototype bool R_POE_GetStatus( uint16_t * data // Status flags pointer ); Description Return the status flags. [data] The status flags shall be stored in the following format.
RX62N Group, RX621 Group 4. Library Reference 4.2.14. Programmable Pulse Generator 1) R_PPG_Create Synopsis Configure a PPG group. Prototype bool R_PPG_Create( uint32_t data1, // Output pin selection uint16_t data2, // Configuration selection uint8_t data3 // Output values ); Description (1/2) Set up a 4-bit PPG group. [data1] Select the outputs to be enabled. If multiple selections are required, use "|" to separate each selection. Select only outputs within one group. • Output pin selection.
RX62N Group, RX621 Group Description (2/2) 4. Library Reference [data2] Operation control If multiple selections are required, use "|" to separate each selection.
RX62N Group, RX621 Group 2) 4. Library Reference R_PPG_Destroy Synopsis Disable PPG outputs. Prototype bool R_PPG_Destroy( uint32_t data // Output pin selection ); Description Disable the pulse output on the selected pins. [data] Select the outputs to be disabled. If multiple selections are required, use "|" to separate each selection. Select only outputs within one group. • Output pin selection. PDL_PPG_PO0 PDL_PPG_PO1 Group 0. PDL_PPG_PO2 PDL_PPG_PO3 PDL_PPG_PO4 PDL_PPG_PO5 Group 1.
RX62N Group, RX621 Group 4. Library Reference Program example #include "r_pdl_ppg.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" void func(void) { /* Disable outputs PO24 and PO26 */ R_PPG_Destroy( PDL_PPG_PO24 | PDL_PPG_PO26 ); } R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 3) 4. Library Reference R_PPG_Control Synopsis Control a PPG group. Prototype bool R_PPG_Control( uint32_t data1, // Group selection uint8_t data2 // Next output values ); Description Set the next output for a PPG group. [data1] Select the group(s) to be modified. If multiple selections are required, use "|" to separate each selection.
RX62N Group, RX621 Group 4. Library Reference 4.2.15. 8-bit Timer 1) R_TMR_Set Synopsis Configure the optional TMR pins. Prototype bool R_TMR_Set( uint8_t data ); Description // Configuration Set up the global TMR options. [data] Configure the global options. Use "|" to separate each selection. • Pin selection (required only if the pin is used for the timer function). PDL_TMR_PIN_TMR0_A or Select the -A or -B pins for TMCI0 and TMRI0.
RX62N Group, RX621 Group 2) 4. Library Reference R_TMR_CreateChannel Synopsis Configure a timer TMR channel.
RX62N Group, RX621 Group Description (2/2) 4. Library Reference [data3] Configure the output control. If multiple selections are required, use "|" to separate each selection. The default settings are shown in bold. Specify PDL_NO_DATA to use the defaults.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_tmr.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" void func(void) { /* Configure TMR0: PCLK, clear after a compare match A */ R_TMR_CreateChannel( 0, PDL_TMR_CLK_PCLK_DIV_1 | PDL_TMR_CLEAR_CM_A, PDL_NO_DATA, 0, 199, 99, PDL_NO_FUNC, PDL_NO_FUNC, PDL_NO_FUNC, 0 ); } R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 3) 4. Library Reference R_TMR_CreateUnit Synopsis Configure a timer TMR unit.
RX62N Group, RX621 Group Description (2/2) 4. Library Reference [data3] Configure the output control. If multiple selections are required, use "|" to separate each selection. The default settings are shown in bold. • Output control for pin TMOy (y = 0 or 2 for n = 0 or 1) PDL_TMR_OUTPUT_IGNORE_CM_A or No change if a compare match A occurs. PDL_TMR_OUTPUT_LOW_CM_A or 0 is output if a compare match A occurs. PDL_TMR_OUTPUT_HIGH_CM_A or 1 is output if a compare match A occurs.
RX62N Group, RX621 Group 4. Library Reference Program example #include "r_pdl_tmr.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" void func(void) { /* Configure TMR unit 0: PCLK, clear after a compare match A */ R_TMR_CreateUnit( 0, PDL_TMR_CLK_PCLK_DIV_1 | PDL_TMR_CLEAR_CM_A, 0, 0, 199, 99, PDL_NO_FUNC, PDL_NO_FUNC, PDL_NO_FUNC, 0 ); } R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 4) 4. Library Reference R_TMR_CreatePeriodic Synopsis Select periodic operation.
RX62N Group, RX621 Group Description (2/2) Return value 4. Library Reference [data5] The interrupt priority level. Select between 1 (lowest priority) and 15 (highest priority). This parameter will be ignored if PDL_NO_FUNC is specified for both parameters func1and func2. True if all parameters are valid and exclusive; otherwise false. Category Timer TMR Reference R_CGC_Set, R_TMR_CreateChannel, R_TMR_CreateUnit Remarks • Function R_CGC_Set must be called before any use of this function.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_tmr.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 5) 4. Library Reference R_TMR_CreateOneShot Synopsis Configure and use a one-shot timer. Prototype bool R_TMR_CreateOneShot( uint8_t data1, // 8-bit (channel) or 16-bit (unit) timer selection uint32_t data2, // Configuration selection float data3, // Period void * func, // Callback function uint8_t data4 // Interrupt priority level ); Description Set up a TMR timer channel or unit for one-shot operation and start the timer.
RX62N Group, RX621 Group Remarks • • • • • • • • 4. Library Reference Function R_CGC_Set must be called before any use of this function. This function is an alternative to R_TMR_CreateChannel and R_TMR_CreateUnit. This function stops the timer on completion, so no other TMR function calls are required. User needs to ensure no higher priority modules using the same pins as required by this function. If a callback function is specified, this function will enable the relevant interrupt.
RX62N Group, RX621 Group 6) 4. Library Reference R_TMR_Destroy Synopsis Disable a TMR timer unit. Prototype bool R_TMR_Destroy( uint8_t data // Unit selection ); Description Shut down a TMR timer unit. [data] The timer unit n (where n = 0 or 1). Unit 0 comprises channels TMR0 and TMR1. Unit 1 comprises channels TMR2 and TMR3. Return value True if the unit selection is valid; otherwise false. Category Timer TMR Reference None.
RX62N Group, RX621 Group 7) 4. Library Reference R_TMR_ControlChannel Synopsis Write to timer channel registers. Prototype bool R_TMR_ControlChannel( uint8_t data1, // Channel selection uint32_t data2, // Configuration selection uint8_t data3, // Register value uint8_t data4, // Register value uint8_t data5 // Register value ); Description Modify a timer channel’s operation, counter and compare registers. [data1] The channel number n (where n = 0, 1, 2 or 3).
RX62N Group, RX621 Group 8) 4. Library Reference R_TMR_ControlUnit Synopsis Write to timer unit registers. Prototype bool R_TMR_ControlUnit( uint8_t data1, // Unit selection uint32_t data2, // Configuration selection uint16_t data3, // Register value uint16_t data4, // Register value uint16_t data5 // Register value ); Description Modify a timer unit’s counter and compare registers. [data1] The unit number n (where n = 0 or 1). [data2] The channel settings to be modified.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_tmr.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" void func(void) { /* Load the unit 1 counter and constants */ R_TMR_ControlUnit( 1, PDL_TMR_COUNTER | PDL_TMR_TIME_CONSTANT_A | \ PDL_TMR_TIME_CONSTANT_B, 0xAAFF, 0x100, 0x5600 ); } R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 9) 4. Library Reference R_TMR_ControlPeriodic Synopsis Control periodic operation. Prototype bool R_TMR_ControlPeriodic( uint8_t data1, // 8-bit (channel) or 16-bit (unit) selection uint32_t data2, // Configuration selection float data3, // The new period or frequency float data4 // The new pulse width or duty cycle ); Description Modify a periodic timer operation.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_tmr.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" void func(void) { /* Change timer TMR1 to 600ns period, 100ns pulse width */ R_TMR_ControlPeriodic( PDL_TMR_TMR1, PDL_TMR_PERIOD, 600E-9, 100E-9 ); } R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 10) 4. Library Reference R_TMR_ReadChannel Synopsis Read from timer channel registers. Prototype bool R_TMR_ReadChannel( uint8_t data1, // Channel selection uint8_t * data2, // A pointer to the data storage location uint8_t * data3, // A pointer to the data storage location uint8_t * data4, // A pointer to the data storage location uint8_t * data5 // A pointer to the data storage location ); Description Read any of the timer’s counter, compare or status flag registers.
RX62N Group, RX621 Group 11) 4. Library Reference R_TMR_ReadUnit Synopsis Read from timer unit registers. Prototype bool R_TMR_ReadUnit( uint8_t data1, // Unit selection uint8_t * data2, // A pointer to the data storage location uint16_t * data3, // A pointer to the data storage location uint16_t * data4, // A pointer to the data storage location uint16_t * data5 // A pointer to the data storage location ); Description Read any of the timer’s counter, compare or status flag registers.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_tmr.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" uint8_t Flags; uint16_t Counter; uint16_t CompareMatchA; uint16_t CompareMatchB; void func(void) { /* Read the status flags and registers for TMR unit 0 */ R_TMR_ReadUnit( 0, &Flags, &Counter, &CompareMatchA, &CompareMatchB ); } R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 4. Library Reference 4.2.16. Compare Match Timer 1) R_CMT_Create Synopsis Configure a CMT channel. Prototype bool R_CMT_Create( uint8_t data1, uint16_t data2, float data3, void * func, uint8_t data4 ); Description // Timer channel selection // Configuration selection // Period, frequency or register data // Callback function // Interrupt priority level Set up a Compare Match Timer channel and start the timer. [data1] The channel number n (where n = 0, 1, 2 or 3).
RX62N Group, RX621 Group Remarks 4. Library Reference • Function R_CGC_Set must be called before any use of this function. • If a callback function is specified, this function will enable the relevant interrupt. Please see the notes on callback function use in §6. • A callback function is executed by the interrupt processing function. This means that no other interrupt can be processed until the callback function has completed. • Ensure that the timer channel is stopped before calling this function.
RX62N Group, RX621 Group 2) 4. Library Reference R_CMT_CreateOneShot Synopsis Configure a CMT channel as a one-shot event. Prototype bool R_CMT_CreateOneShot( uint8_t data1, // Timer channel selection uint16_t data2, // Configuration selection float data3, // Period void * func, // Callback function uint8_t data4 // Interrupt priority level ); Description Set up a Compare Match Timer channel and start the timer. [data1] The channel number n (where n = 0, 1, 2 or 3). [data2] Configure the timer.
RX62N Group, RX621 Group Remarks 4. Library Reference • Function R_CGC_Set must be called before any use of this function. • Function R_CMT_Create is not required. • Ensure that the timer channel is stopped before calling this function. Note that the timer is stopped automatically when the one-shot period is reached. • If a callback function is specified, this function will enable the relevant interrupt. Please see the notes on callback function use in §6.
RX62N Group, RX621 Group 3) 4. Library Reference R_CMT_Destroy Synopsis Disable a CMT unit. Prototype bool R_CMT_Destroy( uint8_t data // Unit selection ); Description Shut down a CMT unit. [data] The timer unit n (where n = 0 or 1). Unit 0 comprises channels CMT0 and CMT1. Unit 1 comprises channels CMT2 and CMT3. Return value True if the unit selection is valid; otherwise false.
RX62N Group, RX621 Group 4) 4. Library Reference R_CMT_Control Synopsis Control CMT operation. Prototype bool R_CMT_Control( uint8_t data1, // Channel selection uint16_t data2, // Configuration selection float data3 // Period, frequency or register data ); Description Modify the operation of a CMT channel. [data1] The channel number n (where n = 0, 1, 2 or 3). [data2] Configure the timer channel. To set multiple options at the same time, use "|" to separate each value.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_cmt.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" void func(void) { /* Change channel 2 to 1ms period */ R_CMT_Control( 2, PDL_CMT_STOP | PDL_CMT_PERIOD | PDL_CMT_START, 1E-3 ); } R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 5) 4. Library Reference R_CMT_Read Synopsis Read CMT channel status and registers. Prototype bool R_CMT_Read( uint8_t data1, uint8_t * data2, uint16_t * data3 ); Description // Channel selection // A pointer to the data storage location // A pointer to the data storage location Read and store the counter value and status flag. [data1] The channel number n (where n = 0, 1, 2 or 3). [data2] The compare match status flag shall be stored in the following format.
RX62N Group, RX621 Group 4. Library Reference 4.2.17. Real-time Clock 1) R_RTC_Create Synopsis Configure the Real-time clock.
RX62N Group, RX621 Group Description (2/2) 4. Library Reference [data4] The alarm day of the week and time in hours, minutes and seconds. BCD format is used. If not required, specify PDL_NO_DATA. b31 – b24 Day of week Valid from 0 to 6. 0 = Sunday. Specify 0xFF for automatic calculation using the values in data5. b23 – b16 Hours Valid from 0 to 23. b15 – b8 Minutes Valid from 0 to 59. b7 – b0 Seconds Valid from 0 to 59. [data5] The alarm year, month and day. BCD format is used.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_rtc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 2) 4. Library Reference R_RTC_Control Synopsis Modify the Real-time clock operation. Prototype bool R_RTC_Control( uint32_t data1, // Control selection uint16_t data2, // Update selection uint32_t data3, // Current time uint32_t data4, // Current date uint32_t data5, // Alarm time uint32_t data6 // Alarm date ); Description (1/2) Change clock settings and update the time or date. [data1] Change the clock operation.
RX62N Group, RX621 Group Description (2/2) 4. Library Reference [data2] Select the values to be changed. To set multiple options at the same time, use "|" to separate each value. If no change is required, specify PDL_NO_DATA. • Select the time counters to be updated, using values supplied in parameter data3.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_rtc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" void func(void) { /* Disable the alarm calendar, and update the alarm time */ R_RTC_Control( PDL_RTC_ALARM_DATE_DISABLE, PDL_RTC_UPDATE_ALARM_TIME, PDL_NO_DATA, PDL_NO_DATA, 0x00105300, // Alarm at 10:53.
RX62N Group, RX621 Group 3) 4. Library Reference R_RTC_Read Synopsis Read the Real-time clock status flags and counters. Prototype bool R_RTC_Read( uint8_t * data1, uint32_t * data2, uint32_t * data3 ); Description // A pointer to the flags storage location // A pointer to the data storage location // A pointer to the data storage location Read the Clock counters registers and status flags. [data1] The clock status shall be stored in the following format.
RX62N Group, RX621 Group 4. Library Reference 4.2.18. Watchdog Timer 1) R_WDT_Create Synopsis Configure the Watchdog timer. Prototype bool R_WDT_Create( uint16_t data1, // Configuration selection void * func, // Callback function uint8_t data2 // Interrupt priority level ); Description Set up and start the Watchdog timer. [data1] Configure the timer. To set multiple options at the same time, use "|" to separate each value. The default settings are shown in bold.
RX62N Group, RX621 Group Remarks 4. Library Reference • Function R_CGC_Set should be called before any use of this function. • If a callback function is specified, this function will enable the relevant interrupt. Please see the notes on callback function use in §6. • A callback function is executed by the interrupt processing function. This means that no other interrupt can be processed until the callback function has completed.
RX62N Group, RX621 Group 2) 4. Library Reference R_WDT_Control Synopsis Control the Watchdog operation. Prototype bool R_WDT_Control( uint8_t data // Control selection ); Description Modify the operation of the Watchdog timer. [data] Configure the timer channel. To set multiple options at the same time, use "|" to separate each value. Return value • Counter stop PDL_WDT_STOP Disable the counter clock source. • Counter update PDL_WDT_RESET_COUNTER Reset the counter.
RX62N Group, RX621 Group 3) 4. Library Reference R_WDT_Read Synopsis Read the Watchdog timer status and registers. Prototype bool R_WDT_Read( uint8_t * data ); Description // A pointer to the data storage location Read and store the status flags. [data] The timer status shall be stored in the following format. b7 – b1 0 Return value True.
RX62N Group, RX621 Group 4. Library Reference 4.2.19. Independent Watchdog Timer 1) R_IWDT_Set Synopsis Configure the Independent Watchdog operation. Prototype bool R_IWDT_Set( uint16_t data ); Description // Configuration selection Select the operation of the Independent Watchdog timer. [data] Configure the timer options. Use "|" to separate each value.
RX62N Group, RX621 Group 2) 4. Library Reference R_IWDT_Control Synopsis Control the Independent Watchdog operation. Prototype bool R_IWDT_Control( uint8_t data // Control selection ); Description Modify the operation of the Independent Watchdog timer. [data] Control the timer. • Counter start / refresh PDL_IWDT_REFRESH Return value True if the parameter is valid; otherwise false.
RX62N Group, RX621 Group 3) 4. Library Reference R_IWDT_Read Synopsis Read the watchdog timer status and counter. Prototype bool R_IWDT_Read( uint16_t * data // A pointer to the data storage location ); Description Read and store the status flags. [data] The timer status shall be stored in the following format. b15 0 Return value b14 0: Not underflowed 1: An underflow has occurred The current counter value True. Category Independent Watchdog Timer Reference None.
RX62N Group, RX621 Group 4. Library Reference 4.2.20. Serial Communication Interface 1) R_SCI_Set Synopsis Configure the SCI pin selection. Prototype bool R_SCI_Set( uint8_t data ); Description // Configuration Set up the global SCI options. [data] Configure the global options. Use "|" to separate each selection. • Pin selection (required only if the pins are used for the SCI function). PDL_SCI_PIN_SCI1_A or Select the -A or -B pins for RxD1, SCK1, TxD1.
RX62N Group, RX621 Group 2) 4. Library Reference R_SCI_Create Synopsis SCI channel setup. Prototype bool R_SCI_Create( uint8_t data1, uint32_t data2, uint32_t data3, uint8_t data4 ); Description (1/3) // Channel selection // Channel configuration // Bit rate or register value // Interrupt priority level Set up the selected SCI channel. [data1] Select channel SCIn (where n = 0 to 6, but not 4). [data2] Configure the channel. If multiple selections are required, use "|" to separate each selection.
RX62N Group, RX621 Group Description (2/3) 4. Library Reference Options which are available in Clock Synchronous mode • Data clock source selection PDL_SCI_CLK_INT_OUT or PDL_SCI_CLK_EXT Select the On-chip baud rate generator. The SCKn pin outputs the bit clock. Input the clock to the SCKn pin.
RX62N Group, RX621 Group Description (3/3) 4. Library Reference [data3] Select the SCI transfer rate. See the Remarks section for the maximum rate that the device can support. The format may be either: • The transfer bit rate in bits per second (bps). The clock division values will be calculated using this value. This format is valid only when the on-chip baud rate generator is selected as the data clock source (in parameter data2). Or the following, using "|" to separate each selection.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_sci.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 3) 4. Library Reference R_SCI_Destroy Synopsis Shut down a SCI channel. Prototype bool R_SCI_Destroy( uint8_t data // Channel selection ); Description Stop data flow and shutdown the selected SCI channel. [data] Select channel SCIn (where n = 0 to 6, but not 4). Return value True if all parameters are valid; otherwise false. Category SCI Reference None. Remarks • The SCI channel is put into the power-down state.
RX62N Group, RX621 Group 4) 4. Library Reference R_SCI_Send Synopsis Transmit data on a SCI channel. Prototype bool R_SCI_Send( uint8_t data1, uint16_t data2, uint8_t * data3, uint16_t data4, void * func ); Description // Channel selection // Channel configuration (and Target Station ID) // Data start address // Data count // Callback function Transmit data on the specified serial channel. [data1] Select channel SCIn (where n = 0 to 6, but not 4). [data2] Control options.
RX62N Group, RX621 Group Remarks 4. Library Reference • The compiler adds a null character to the end of string constants. • If a callback function is specified, transmission interrupts are used. Please see the notes on callback function usage in §6. • If polling mode is used, the TXI and TEND flags will be used to manage the data transmission. If the SCI channel’s control registers are directly modified by the user, this function may lock up. • The maximum number of characters to be transmitted is 65535.
RX62N Group, RX621 Group 5) 4. Library Reference R_SCI_Receive Synopsis Receive data on a SCI channel. Prototype bool R_SCI_Receive( uint8_t data1, uint16_t data2, uint8_t * data3, uint16_t data4, void * func1, void * func2 ); Description // Channel selection // Channel configuration (and Station ID of receiving device) // Data start address // Receive threshold // Callback function // Callback function Enable SCI reception and acquire any incoming data.
RX62N Group, RX621 Group 4. Library Reference Category SCI Reference Remarks R_SCI_Create, R_SCI_Control, R_SCI_GetStatus • The maximum number of characters to be received is 65535. • Wait until a transmission on the same channel is complete before calling this function. • If callback function func1 is specified, reception interrupts are used. Please see the notes on callback function usage in §6. • If polling mode is used, the RXI flag will be used to manage the data reception.
RX62N Group, RX621 Group 6) 4. Library Reference R_SCI_Control Synopsis Control the SCI channel. Prototype bool R_SCI_Control( uint8_t data1, // Channel selection uint8_t data2 // Channel control ); Description Stops SCI transmission or reception. [data1] Select channel SCIn (where n = 0 to 6, but not 4). [data2] Control the channel. If multiple selections are required, use "|" to separate each selection. • Select the process to be stopped. Stop the transmission process.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_sci.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" void func(void) { /* Terminate SCI reception on channel 0 */ R_SCI_Control( 0, PDL_SCI_STOP_RX ); } R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 7) 4. Library Reference R_SCI_GetStatus Synopsis Check the status of an SCI channel. Prototype bool R_SCI_GetStatus( uint8_t data1, uint8_t * data2, uint8_t * data3, uint16_t * data4, uint16_t * data5 ); Description // Channel selection // Status flags // Last byte received // Bytes transmitted // Bytes received Acquires the channel status and the byte counts [data1] Select channel SCIn (where n = 0 to 6, but not 4).
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_sci.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" uint8_t StatusValue; uint16_t TxChars; uint16_t RxChars; void func(void) { /* Read the status of SCI channel 0 */ R_SCI_GetStatus( 0, &StatusValue, PDL_NO_PTR, &TxChars, &RxChars ); } R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 4. Library Reference 4.2.21. CRC calculator 1) R_CRC_Create Synopsis Configure the CRC calculator. Prototype bool R_CRC_Create( uint8_t data // Configuration ); Description Enable the CRC and set the operating conditions. [data] Calculation options. To set multiple options at the same time, use "|" to separate each value.
RX62N Group, RX621 Group 2) 4. Library Reference R_CRC_Destroy Synopsis Shut down the CRC calculator. Prototype bool R_CRC_Destroy( void // No parameter is required ); Description Put the CRC calculator into the Power-down state, with minimal power consumption. Return value True. Category CRC Reference R_CRC_Create Remarks • None. Program example /* RPDL definitions */ #include "r_pdl_crc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 3) 4. Library Reference R_CRC_Write Synopsis Write data into the CRC calculation register. Prototype bool R_CRC_Write( uint8_t data // The data to be used for the calculation ); Description Write the data into the data input register. [data] The data to be written into the register. Return value True. Category CRC Reference R_CRC_Create Remarks • None. Program example /* RPDL definitions */ #include "r_pdl_crc.
RX62N Group, RX621 Group 4) 4. Library Reference R_CRC_Read Synopsis Read the CRC calculation result. Prototype bool R_CRC_Read( uint8_t data1, uint16_t * data2 ); Description // Control // Data storage location Reads and stores the CRC calculation result. [data1] Control the behaviour of the CRC unit. The default setting is shown in bold. Specify PDL_NO_DATA to use the default.
RX62N Group, RX621 Group 4. Library Reference 4.2.22. I²C Bus Interface 1) R_IIC_Create Synopsis I²C channel setup.
RX62N Group, RX621 Group Description (2/3) • Noise filter control PDL_IIC_NF_DISABLE or PDL_IIC_NF_1 or PDL_IIC_NF_2 or PDL_IIC_NF_3 or PDL_IIC_NF_4 4. Library Reference Select the number of stages in the noise filter. [data3] Detection settings. Specify PDL_NO_DATA to use the defaults. • NACK Transmission Arbitration Lost Detection control PDL_IIC_NTALD_DISABLE or Disable or enable arbitration to be lost when an ACK is PDL_IIC_NTALD_ENABLE detection during transmission of a NACK in receive mode.
RX62N Group, RX621 Group Description (3/3) 4. Library Reference [data8] Rise and fall time compensation. If the transfer rate is specified in bits per second, the high-level and low-level durations can be adjusted to allow for application-dependent rise and fall times. If unsure, use 0. b31 - b16 The SCL rise time in nanoseconds. Valid from 0 to 65535. Return value b15 - b0 The SCL fall time in nanoseconds. Valid from 0 to 65535.
RX62N Group, RX621 Group Remarks 4. Library Reference • Function R_CGC_Set must be called before any use of this function. • This function configures each I²C pin that is required for operation. User needs to ensure no higher priority modules using the same pins as required by I²C. • The 7 or 10-bit slave addresses should use the format: b15 - b8 b7 - b1 b0 7-bit address b15 - b11 - b10 - b1 10-bit address b0 - • The timing limits depend on the frequency of the internal reference clock (IRC).
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_iic.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 2) 4. Library Reference R_IIC_Destroy Synopsis Disable an I²C channel. Prototype bool R_IIC_Destroy( uint8_t data // Channel selection ); Description Shut down the selected I²C module. [data] Select channel IICn (where n = 0 or 1). Return value True if the parameter is valid; otherwise false. Category I²C Reference R_IIC_Create Remarks • The I²C module is put into the power-down state. Program example /* RPDL definitions */ #include "r_pdl_iic.
RX62N Group, RX621 Group 3) 4. Library Reference R_IIC_MasterSend Synopsis Write data to a slave device. Prototype bool R_IIC_MasterSend( uint8_t data1, // Channel selection uint16_t data2, // Channel configuration uint16_t data3, // Slave address uint8_t * data4, // Data start address uint16_t data5, // Data count void * func, // Callback function uint8_t data6 // Interrupt priority level ); Description Transmit data on the specified channel. [data1] Select channel IICn (where n = 0 or 1).
RX62N Group, RX621 Group 4. Library Reference [data6] The interrupt priority level. Select between 1 (lowest priority) and 15 (highest priority). This parameter will be ignored if PDL_NO_FUNC is specified for parameter func. Return value Category True if all parameters are valid, exclusive and achievable and a normal transfer completed; otherwise false. I²C Reference R_IIC_Create, R_IIC_GetStatus Remarks • If a callback function is specified, transmission interrupts are used.
RX62N Group, RX621 Group 4) 4. Library Reference R_IIC_MasterReceive Synopsis Read data from a slave device. Prototype bool R_IIC_MasterReceive( uint8_t data1, // Channel selection uint16_t data2, // Channel configuration uint16_t data3, // Slave address uint8_t * data4, // Data start address uint16_t data5, // Receive threshold void * func, // Callback function uint8_t data6 // Interrupt priority level ); Description Read data over an I²C channel and store it.
RX62N Group, RX621 Group Category I²C Reference R_IIC_Create, R_IIC_GetStatus, R_IIC_MasterReceiveLast Remarks 4. Library Reference • If a callback function is specified, reception interrupts are used. Please see the notes on callback function usage in §6. • If the previous transfer did not issue a Stop condition, a Repeated Start condition shall be generated. • The last byte to be read shall be completed with a NACK signal.
RX62N Group, RX621 Group 5) 4. Library Reference R_IIC_MasterReceiveLast Synopsis Complete a DMAC or DTC-based read process. Prototype bool R_IIC_MasterReceiveLast( uint8_t data1, // Channel selection uint8_t * data2 // Data storage address ); Description Read one data byte with NACK and stop. [data1] Select channel IICn (where n = 0 or 1). [data2] The storage location for the data byte. Return value True if all parameters are valid and the function completed; otherwise false.
RX62N Group, RX621 Group 6) 4. Library Reference R_IIC_SlaveMonitor Synopsis Monitor the bus. Prototype bool R_IIC_SlaveMonitor( uint8_t data1, // Channel selection uint16_t data2, // Channel configuration uint8_t * data3, // Receive data start address uint16_t data4, // Receive threshold void * func, // Callback function uint8_t data5 // Interrupt priority level ); Description Monitor the bus until an address match occurs and store any data received.
RX62N Group, RX621 Group Remarks 4. Library Reference • If a callback function is specified, interrupts are used. Use R_IIC_GetStatus in the callback function to identify the activity that has occurred. Please see the notes on callback function usage in §6. • If no callback function is specified, this function will read the status flags to monitor the bus activity. Use R_IIC_GetStatus to identify the activity that has occurred.
RX62N Group, RX621 Group 7) 4. Library Reference R_IIC_SlaveSend Synopsis Write data to a master device. Prototype bool R_IIC_SlaveSend( uint8_t data1, // Channel selection uint8_t * data2, // Data start address uint16_t data3 // Data count ); Description Transmit data on the specified channel. [data1] Select channel IICn (where n = 0 or 1). [data2] The start address of the data to be sent. [data3] The number of bytes available to be sent.
RX62N Group, RX621 Group 8) 4. Library Reference R_IIC_Control Synopsis I²C channel control. Prototype bool R_IIC_Control( uint8_t data1, // Channel selection uint8_t data2 // Control options ); Description Modify the operation of the selected I²C channel. [data1] Select channel IICn (where n = 0 or 1). [data2] Control the channel. If multiple selections are required, use "|" to separate each selection. • Stop generation PDL_IIC_STOP Issue a Stop condition.
RX62N Group, RX621 Group 9) 4. Library Reference R_IIC_GetStatus Synopsis Read the status for an I²C channel. Prototype bool R_IIC_GetStatus( uint8_t data1, uint32_t * data2, uint16_t * data3, uint16_t * data4 ); Description // Channel selection // Status flags // Transmitted bytes // Received bytes Read the status registers for the selected I²C channel. [data1] Select channel IICn (where n = 0 or 1). [data2] The status flags shall be stored in the format below.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_iic.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" void func(void) { uint32_t status_flags; uint16_t tx_count; /* Read the status of channel 0 */ R_IIC_GetStatus( 0, &status_flags, &tx_count, PDL_NO_PTR ); } R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 4. Library Reference 4.2.23. Serial Peripheral Interface 1) R_SPI_Create Synopsis Configure an SPI channel. Prototype bool R_SPI_Create( uint8_t data1, uint32_t data2, uint32_t data3, uint32_t data4, uint32_t data5 ); Description (1/3) // Channel selection // Channel configuration // Data format // Extended timing control // Bit rate or register value Set up the selected SPI channel. [data1] Select channel SPIn (where n = 0 to 1).
RX62N Group, RX621 Group Description (2/3) 4. Library Reference [data3] Configure the data format. If multiple selections are required, use "|" to separate each selection. The default settings are shown in bold. • Buffer size PDL_SPI_BUFFER_64 or PDL_SPI_BUFFER_128 Select a buffer size of 64 bits (up to four 16-bit frames) or 128 bits (up to four 32-bit frames). • Frame configuration selection (refer to figure 32.2 in the hardware manual).
RX62N Group, RX621 Group Description (3/3) 4. Library Reference [data5] The format must be either: • The maximum required bit rate. Or: • b31 1 b30 to b8 0 b7 – b0 The SPBR register value. If only Slave mode will be used, specify PDL_NO_DATA. Return value True if all parameters are valid; otherwise false. Category SPI Reference R_CGC_Set, R_SPI_Command Remarks • Function R_CGC_Set must be called before any use of this function. • -A or –B pin selection is not available on the 85-pin package.
RX62N Group, RX621 Group 2) 4. Library Reference R_SPI_Destroy Synopsis Shutdown an SPI channel. Prototype bool R_SPI_Destroy( uint8_t data // Channel selection ); Description Shutdown the selected SPI channel. [data] Select channel SPIn (where n = 0 to 1). Return value True if all parameters are valid; otherwise false. Category SPI Reference R_SPI_Create Remarks • The SPI channel is put into the power-down state. Program example /* RPDL definitions */ #include "r_pdl_spi.
RX62N Group, RX621 Group 3) 4. Library Reference R_SPI_Command Synopsis Configure an SPI command. Prototype bool R_SPI_Command( uint8_t data1, // Channel selection uint8_t data2, // Command selection uint32_t data3, // Command options uint8_t data4 // Extended timing control ); Description (1/2) Select the options for a command. [data1] Select channel SPIn (where n = 0 to 1). [data2] Select command n (where n = 0 to 7). [data3] Select the command options.
RX62N Group, RX621 Group Description (2/2) 4. Library Reference [data4] Extended timing control. If multiple selections are required, use "|" to separate each selection. The default settings are shown in bold. For Slave mode, select PDL_NO_DATA. • Extended timing selection PDL_SPI_CLOCK_DELAY_MINIMUM or PDL_SPI_CLOCK_DELAY_EXTENDED Select the minimum or extended delay between the assertion of the SSL pin and the start of RSPCK oscillation.
RX62N Group, RX621 Group 4) 4. Library Reference R_SPI_Transfer Synopsis Transfer data over an SPI channel.
RX62N Group, RX621 Group 4. Library Reference Category SPI Reference R_SPI_Create, R_DMAC_GetStatus, R_DTC_GetStatus, R_SPI_GetStatus Remarks • • • • The amount of data for must match the total number of transfer frames (refer to parameter data3 in R_SPI_Create). If a callback function is specified and DMAC / DTC control is not used, interrupts are used to handle the data transfer. Please see the notes on callback function usage in §6.
RX62N Group, RX621 Group 5) 4. Library Reference R_SPI_Control Synopsis Control an SPI channel. Prototype bool R_SPI_Control( uint8_t data1, // Channel selection uint8_t data2, // Control options uint32_t data3 // Extended timing control ); Description Modify the operation of the selected SPI channel. [data1] Select channel SPIn (where n = 0 to 1). [data2] Control the channel. If multiple selections are required, use "|" to separate each selection. All items are optional.
RX62N Group, RX621 Group Category SPI Reference R_SPI_Create Remarks • 4. Library Reference If a channel is disabled using PDL_SPI_DISABLE, call R_SPI_Create to resume channel operations. Program example /* RPDL definitions */ #include "r_pdl_spi.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 6) 4. Library Reference R_SPI_GetStatus Synopsis Check the status of an SPI channel. Prototype bool R_SPI_GetStatus( uint8_t data1, // Channel selection uint16_t * data2, // Status flags uint16_t * data3 // Sequence count ); Description Acquires the SPI channel status. [data1] Select channel SPIn (where n = 0 to 1). [data2] The status flags shall be stored in the format below.
RX62N Group, RX621 Group 4. Library Reference 4.2.24. 12-bit Analog to Digital Converter 1) R_ADC_12_Create Synopsis Configure the 12-bit ADC unit. Prototype bool R_ADC_12_Create( uint8_t data1, // Unit selection uint32_t data2, // Conversion options uint16_t data3, // Trigger selection uint16_t data4, // Value addition mode options void * func, // Callback function uint8_t data5 // Interrupt priority level ); Description (1/2) Set the ADC mode and operating condition.
RX62N Group, RX621 Group Description (2/2) 4. Library Reference [data3] Trigger control selection. To set multiple options at the same time, use "|" to separate each value. The default settings are shown in bold.
RX62N Group, RX621 Group Remarks 4. Library Reference • Interrupts are enabled automatically if a callback function is specified. Please see the notes on callback function usage in §6. • If an external trigger is used, the low-level pulse width must be at least 1.5 PCLK cycles. • This function brings the converter unit out of the power-down state. • A callback function is executed by the interrupt processing function.
RX62N Group, RX621 Group 2) 4. Library Reference R_ADC_12_Destroy Synopsis Shut down the ADC unit. Prototype bool R_ADC_12_Destroy( uint8_t data // ADC unit selection ); Description Put the ADC into the Power-down state, with minimal power consumption. [data] Select the ADC unit to be shut down. This must always be 0. Return value True if a valid unit is selected; otherwise false.
RX62N Group, RX621 Group 3) 4. Library Reference R_ADC_12_Control Synopsis Start or stop an ADC unit. Prototype bool R_ADC_10_Control( uint8_t data // Conversion unit control ); Description Controls start / stop operation of the specified ADC. [data] To select multiple options at the same time, use "|" to separate each value. • On / off control PDL_ADC_12_0_ON or PDL_ADC_12_0_OFF Start a software-triggered conversion or re-enable the trigger. Stop the conversion (and disable all triggers).
RX62N Group, RX621 Group 4) 4. Library Reference R_ADC_12_Read Synopsis Read the ADC conversion results. Prototype bool R_ADC_12_Read( uint8_t data1, // ADC unit selection uint16_t * data2 // Pointer to the buffer where the converted values are to be stored ); Description Reads the conversion values for an ADC unit. [data1] Select the ADC unit to be used. This must always be 0. [data2] Specify a pointer to an array where the results shall be stored.
RX62N Group, RX621 Group 4. Library Reference 4.2.25. 10-bit Analog to Digital Converter 1) R_ADC_10_Create Synopsis Configure a 10-bit ADC unit. Prototype bool R_ADC_10_Create( uint8_t data1, // ADC unit selection uint32_t data2, // ADC configuration uint32_t data3, // ADC conversion clock frequency float data4, // ADC input sampling time void * func, // Callback function uint8_t data5 // Interrupt priority level ); Description (1/2) Set the ADC’s mode and operating condition.
RX62N Group, RX621 Group Description (2/2) 4. Library Reference • Trigger selection PDL_ADC_10_TRIGGER_SOFTWARE or PDL_ADC_10_TRIGGER_MTU0_MTU4_CMIC_A or PDL_ADC_10_TRIGGER_TMR0_CM_A or PDL_ADC_10_TRIGGER_ADTRG0 or PDL_ADC_10_TRIGGER_ADTRG1 or PDL_ADC_10_TRIGGER_MTU0_CMIC or PDL_ADC_10_TRIGGER_MTU6_MTU10_CMIC_A or PDL_ADC_10_TRIGGER_MTU4_CM or PDL_ADC_10_TRIGGER_MTU10_CM Software trigger. Compare-match / input-capture A signal from MTU0 to MTU4. Compare-match A signal from TMR channel 0.
RX62N Group, RX621 Group Category References Remarks 4. Library Reference ADC R_CGC_Set, R_ADC_10_Control, R_ADC_10_Read • This function configures the selected pin(s) for ADC operation by setting the direction to input and turning off the input buffer. The port control settings for any ADC pins that subsequently become inactive are not modified. • This function brings the selected converter unit out of the power-down state. • Interrupts are enabled automatically if a callback function is specified.
RX62N Group, RX621 Group 4. Library Reference Program example /* RPDL definitions */ #include "r_pdl_adc_10.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" /* ADC unit 1 callback function */ void ADC1IntFunc(void){} void func(void) { /* Set up ADC 1 at 48 MHz in single mode using AN1 with 0.6 µs sampling time */ R_ADC_10_Create( 1, PDL_ADC_10_CHANNELS_OPTION_2, 48E6, 0.
RX62N Group, RX621 Group 2) 4. Library Reference R_ADC_10_Destroy Synopsis Shut down an ADC unit. Prototype bool R_ADC_10_Destroy( uint8_t data // ADC unit selection ); Description Put the ADC into the Power-down state, with minimal power consumption. [data] Select the ADC unit (0 or 1) to be shut down. Return value True if a valid unit is selected; otherwise false.
RX62N Group, RX621 Group 3) 4. Library Reference R_ADC_10_Control Synopsis Start or stop an ADC unit. Prototype bool R_ADC_10_Control( uint16_t data // Conversion unit control ); Description Controls start / stop operation of the specified ADC. [data] To select multiple units at the same time, use "|" to separate each value. • On / off control PDL_ADC_10_0_ON or PDL_ADC_10_0_OFF PDL_ADC_10_1_ON or PDL_ADC_10_1_OFF Start or stop ADC unit 0 conversion. Start or stop ADC unit 1 conversion.
RX62N Group, RX621 Group 4) 4. Library Reference R_ADC_10_Read Synopsis Read the ADC conversion results. Prototype bool R_ADC_10_Read( uint8_t data1, // ADC unit selection uint16_t * data2 // Pointer to the buffer where the converted values are to be stored ); Description Reads the conversion values for an ADC unit. [data1] Select the ADC unit (0 or 1) to be read. [data2] Specify a pointer to a variable or array where the results shall be stored.
RX62N Group, RX621 Group 4. Library Reference 4.2.26. 10-bit Digital to Analog Converter 1) R_DAC_10_Create Synopsis Configure the 10-bit DAC module. Prototype bool R_DAC_10_Create( uint8_t data1, // Configuration uint16_t data2, // Output value uint16_t data3 // Output value ); Description Enable the DAC module and set the operating conditions. [data1] Configuration options. To set multiple options at the same time, use "|" to separate each value. The default settings are shown in bold.
RX62N Group, RX621 Group 2) 4. Library Reference R_DAC_10_Destroy Synopsis Disable a DAC channel. Prototype bool R_DAC_10_Destroy( uint8_t data // Channel selection ); Description Disable the channel output. [data1] Disable selection. To set multiple options at the same time, use "|" to separate each value. PDL_DAC_10_CHANNEL_0 Disable channel 0 PDL_DAC_10_CHANNEL_1 Disable channel 1 Return value True if the parameter is valid; otherwise false.
RX62N Group, RX621 Group 3) 4. Library Reference R_DAC_10_Write Synopsis Write data to a DAC channel. Prototype bool R_DAC_10_Write( uint8_t data1, // Channel selection uint16_t data2, // Output value uint16_t data3 // Output value ); Description Write data to the selected DAC channel(s). [data1] Select the DAC channel output to be modified. PDL_DAC_10_CHANNEL_0 Select channel 0 PDL_DAC_10_CHANNEL_1 Select channel 1 [data2] The value to be written to the channel 0 output register.
RX62N Group, RX621 Group 5. Usage Examples 5. Usage Examples This chapter shows programming examples for each driver in this library. 5.1. Interrupt control Figure 5-1 shows an example of external interrupt use. Pin IRQ0-A is used to detect a falling edge and generates an interrupt. Pin IRQ1-B is used to detect a falling edge and is polled. Pin IRQ2-A is used to detect a low-level signal and generates an interrupt. Further interrupts are prevented until the signal has returned to the high level.
RX62N Group, RX621 Group 5.
RX62N Group, RX621 Group 5. Usage Examples 5.2. I/O Port Figure 5-2 shows examples of I/O port configuration, reading and writing. /* Peripheral driver function prototypes */ #include "r_pdl_io_port.h" #include "r_pdl_pfc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 5. Usage Examples /* Read the direction for pin P03 */ R_IO_PORT_ReadControl( PDL_IO_PORT_0_3, PDL_IO_PORT_DIRECTION, &direction ); /* Set the lower 4 bits on port P1 to output */ R_IO_PORT_ModifyControl( PDL_IO_PORT_1, PDL_IO_PORT_DIRECTION | PDL_IO_PORT_OR, 0x0F ); /* Enable the pull-up on pin PA3 */ R_IO_PORT_ModifyControl( PDL_IO_PORT_A_3, PDL_IO_PORT_PULL_UP | PDL_IO_PORT_OR, 1 ); } Figure 5-2: Example of I/O Port Operations R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 5. Usage Examples 5.3. Low Power Consumption 5.3.1. Software Standby Mode Figure 5-3 shows an example of entering Software Standby mode through Low Power Consumption control. /* Peripheral driver function prototypes */ #include "r_pdl_lpc.h" #include "r_pdl_intc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 5.3.2. 5. Usage Examples Deep Software Standby Mode Figure 5-4 shows an example of entering Deep Software Standby mode through Low Power Consumption control. R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 5. Usage Examples /* PDL functions */ #include "r_pdl_lpc.h" #include "r_pdl_intc.h" /* PDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 5. Usage Examples 5.4. Voltage Detection Circuit Figure 5-5 shows an example of Voltage detection circuit usage. If the supply voltage drops below 3.15V (Vdet2), the callback function is called. If the supply voltage drops below 2.85V (Vdet1), the MCU is reset. /* Peripheral driver function prototypes */ #include "r_pdl_lvd.h" #include "r_pdl_intc.h" /* PDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 5. Usage Examples 5.5. Bus Controller 5.5.1. External bus, CS area Figure 5-6 shows an example of external bus controller usage. /* Peripheral driver function prototypes */ #include "r_pdl_bsc.h" #include "r_pdl_cgc.h" #include "r_pdl_intc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 5. Usage Examples 0, 0, 1, 0 ); /* Configure area CS1 */ R_BSC_CreateArea( 1, PDL_BSC_WIDTH_8 | PDL_BSC_WRITE_SINGLE, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 ); /* Write to external areas */ *cs7_location_16 = 0xAA55; *cs1_location_8 = 0xAA; /* Disable area CS1 */ R_BSC_Destroy( 1 ); } Figure 5-6: Example of Bus Controller use R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 5.5.2. 5. Usage Examples External bus, SDRAM area Figure 5-7 shows an example of SDRAM bus controller usage, and the procedure for transition to and recovery from self-refresh mode in deep software standby mode. /* PDL functions */ #include "r_pdl_bsc.h" #include "r_pdl_io_port.h" #include "r_pdl_cgc.h" #include "r_pdl_lpc.h" #include "r_pdl_intc.h" /* PDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 0x0FFFu, 0x00u, 0x00u, 0x02u, 0x00u, 0x02u, 0x01u, 0x00u, 0x00u, 0x00u, 0x0220u 5.
RX62N Group, RX621 Group 5. Usage Examples /* Enter deep software standby mode. An internal reset will occur.
RX62N Group, RX621 Group 5.
RX62N Group, RX621 Group 5. Usage Examples 5.6. DMA controller The following examples show the use of triggers by software, IRQ pin edge detection and SCI transmission. 5.6.1. Software and IRQ triggers Channel 0 will copy the string "Renesas RX62N" into the destination area when a falling edge occurs on pin IRQ3-B. Channel 1 will copy the string "Hello, World" into the destination area as soon as it is enabled. /* PDL functions and definitions */ #include "r_pdl_dmac.h" #include "r_pdl_cgc.
RX62N Group, RX621 Group 5.
RX62N Group, RX621 Group 5. Usage Examples &TransferCount, &SizeCount ); } void DMAC0_transfer_end_handler(void) { /* Invert the port pin */ R_IO_PORT_Modify( PDL_IO_PORT_0_2, PDL_IO_PORT_XOR, 1 ); /* Stop all channels */ R_DMAC_Control( 0, PDL_DMAC_SUSPEND, PDL_NO_PTR, PDL_NO_PTR, PDL_NO_DATA, PDL_NO_DATA, PDL_NO_DATA, PDL_NO_DATA, PDL_NO_DATA ); /* Stop channel 0 */ R_DMAC_Destroy( 0 ); } Figure 5-8: Two examples of DMAC use R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 5.6.2. 5. Usage Examples SCI transmission trigger DMAC Channel 3 will be used to transmit the string "Renesas RX62N". Then the string "Hello, World" will be transmitted by polling. /* PDL functions and definitions */ #include "r_pdl_dmac.h" #include "r_pdl_cgc.h" #include "r_pdl_intc.h" #include "r_pdl_sci.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" /* Required for this example */ #include
RX62N Group, RX621 Group 5.
RX62N Group, RX621 Group 5. Usage Examples /* Stop the SCI */ R_SCI_Control( 2, PDL_SCI_STOP_TX | PDL_SCI_OUTPUT_MARK ); } sci_dma_transfer_complete = true; } Figure 5-9: An example of using the DMAC for serial port transmission R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 5.6.3. 5. Usage Examples SCI reception trigger DMAC channel 2 will transfer 5 received characters into the assigned storage area and then call the callback function. /* PDL functions and definitions */ #include "r_pdl_dmac.h" #include "r_pdl_cgc.h" #include "r_pdl_intc.h" #include "r_pdl_sci.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 5.
RX62N Group, RX621 Group 5. Usage Examples 5.7. Data Transfer Controller 5.7.1. Block transfer mode Figure 5-11 shows an example of Data Transfer Controller usage with a single block transfer. /* Peripheral driver function prototypes */ #include "r_pdl_dtc.h" #include "r_pdl_io_port.h" #include "r_pdl_intc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" /* Required for this example */ #include
RX62N Group, RX621 Group 5.
RX62N Group, RX621 Group 5.7.2. 5. Usage Examples Chain transfer operation Figure 5-12 shows an example of Data Transfer Controller operation, using chain transfer of blocks. Address space destination_string_3 destination_string_2 destination_string_1 1 2 3 Renesas RX62N DTC example Using chain transfer Transfer 1 is triggered by a software interrupt and copies data from ROM into RAM. On completion of transfer 1, transfer 2 is started. On completion of transfer 2, transfer 3 is started.
RX62N Group, RX621 Group 5.
RX62N Group, RX621 Group 5.
RX62N Group, RX621 Group 5. Usage Examples 5.8. 8-bit Timer 5.8.1. Periodic operation Timer channel 0 is configured to provide pulses on pin TMO0, with a pulse width of 500µs and an on-time of 200µs. /* Peripheral driver function prototypes */ #include "r_pdl_tmr.h" #include "r_pdl_cgc.h" #include "r_pdl_intc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" void main(void) { /* Initialise the system clocks */ R_CGC_Set( 12.
RX62N Group, RX621 Group 5. Usage Examples For full flexibility, the R_TMR_CreateChannel() function can be used. In this example, Timer channel 0 is configured to provide pulses on pin TMO0, with a pulse width of 200 ticks of PCLK and a duty cycle of 50%. Note that the output transitions and counter clearing occur after the compare match has occurred. So the values for compare match A and compare match B should be 1 less than the required count.
RX62N Group, RX621 Group 5. Usage Examples 5.9. Compare Match Timer Figure 5-16 shows an example of Compare Match Timer usage. One channel is used to generate interrupts at regular intervals. R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 5. Usage Examples /* Peripheral driver function prototypes */ #include "r_pdl_cmt.h" #include "r_pdl_cgc.h" #include "r_pdl_io_port.h" #include "r_pdl_intc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.h" /* Callback function prototype */ void CMT0_handler(void); void main(void) { /* Initialise the system clocks */ R_CGC_Set( 12.
RX62N Group, RX621 Group 5.10. 5. Usage Examples Real-time Clock Figure 5-17 shows an example of Real-time Clock usage. The sub-clock oscillator is enabled and allowed to settle. The two-second settling time is generated using one CMT call with the peripheral clock (PCLK) set to 12MHz. Other methods can be used, such as multiple calls of the one-shot function. The current time and date are set, with the day of week being calculated by the function. The alarm is set for 10 seconds in the future.
RX62N Group, RX621 Group 5. Usage Examples &Flags, &CurrentTime, PDL_NO_PTR ); } void Alarm_handler(void) { /* Change the alarm */ R_RTC_Control( PDL_NO_DATA, PDL_RTC_UPDATE_ALARM_TIME, PDL_NO_DATA, PDL_NO_DATA, 0x00114310, PDL_NO_DATA ); } Figure 5-17: Example of Real-Time Clock use R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 5.11. 5. Usage Examples Independent Watchdog Timer Figure 5-18 shows an example of Independent Watchdog timer usage. At start-up the underflow is checked to identify if the the reset was caused by the Independent Watchdog timer. The watchdog timer is then configured for a 1024-count timeout period and started.
RX62N Group, RX621 Group 5.12. 5. Usage Examples Serial Communication Interface 5.12.1. SCI Reception Figure 5-19 shows the setting of SCI channels 0 and 1 and the reception of data using interrupts (channel 0) and polling (channel 1). /* Peripheral driver function prototypes */ #include "r_pdl_sci.h" #include "r_pdl_cgc.h" #include "r_pdl_intc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 5.
RX62N Group, RX621 Group 5. Usage Examples 5.12.2. SCI Transmission Figure 5-20 shows the configuration of SCI channels 0 and 1 and the transmission of data (on channel 0) using polling and then interrupts. /* Peripheral driver function prototypes */ #include "r_pdl_sci.h" #include "r_pdl_cgc.h" #include "r_pdl_intc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 5. Usage Examples "Renesas RX", 0, PDL_NO_FUNC ); /* Send another string on channel 0 */ R_SCI_Send( 0, PDL_NO_DATA, "www.renesas.com", 0, SCI0TxFunc ); /* Echo the character on channel 1 */ R_SCI_Send( 1, PDL_NO_DATA, result, 0, PDL_NO_FUNC ); } /* SCI channel 0 transmit complete handler */ void SCI0TxFunc(void) { /* Shut down channel 0 */ R_SCI_Destroy( 0 ); } Figure 5-20: Example of SCI Transmission code R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 5. Usage Examples 5.12.3. Synchronous Transmission and Reception Figure 5-21 shows the configuration of SCI channel 3 as the clock master followed by the simultaneous transmission and reception of data. The Receive function call uses interrupts while the Transmit function uses polling. /* Peripheral driver function prototypes */ #include "r_pdl_sci.h" #include "r_pdl_cgc.h" #include "r_pdl_intc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 5. Usage Examples ); /* Send data (which will also receive data at the same time) */ R_SCI_Send( 3, PDL_NO_DATA, Tx_Data, transfer_size, PDL_NO_FUNC ); /* Ensure the receive interrupt has processed the last byte */ while (data_received == false); /* Process the received data here */ } /* SCI channel 3 receive complete handler */ void SCI3RxFunc (void) { data_received = true; } Figure 5-21: Example of Synchronous Transmission and Reception code R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 5. Usage Examples 5.12.4. SCI Reception in Asynchronous Multi-Processor mode Figure 5-22 shows the setting of SCI channel 2 and the Multi-Processor mode reception of data using interrupts and polling. /* PDL functions */ #include "r_pdl_sci.h" #include "r_pdl_cgc.h" #include "r_pdl_io_port.h" /* PDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 5.
RX62N Group, RX621 Group 5. Usage Examples 5.12.5. SCI Transmission in Asynchronous Multi-Processor mode Figure 5-23 shows the setting of SCI channel 2 and the Multi-Processor mode transmission of data using interrupts and polling. /* PDL functions */ #include "r_pdl_sci.h" #include "r_pdl_cgc.h" /* PDL device-specific definitions */ #include "r_pdl_definitions.h" void SCI1tx(void); uint8_t* send_data0 = "\n\rWelcome to the Renesas RX62N.
RX62N Group, RX621 Group 5. Usage Examples /* Send Target Station ID (0x01) by internal polling */ R_SCI_Send( 2, 0x0100 | PDL_SCI_MP_ID_CYCLE, PDL_NO_PTR, 0, PDL_NO_FUNC ); /* Send data to Target Station (ID = 0x01), by polling */ R_SCI_Send( 2, PDL_NO_DATA, send_data, 0, PDL_NO_FUNC ); } void SCI1tx(void) { tx_end = true; } Figure 5-23: Example of SCI Transmission code in Asynchronous Multi-Processor mode R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 5.13. 5. Usage Examples CRC calculator Figure 5-24 shows an example of CRC usage. The payload and CRC checksum have been received from a remote unit. The CRC calculator is used to check that the payload is correct. /* Peripheral driver function prototypes */ #include "r_pdl_crc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 5.14. 5. Usage Examples I²C Bus Interface In the following examples, the bus activity will be illustrated using the following format. S Slave address R/W A Data From the master A Data A Data A Data A P A = Acknowledge (SDA held low) A = Not Acknowledge (SDA released high) From the slave S = Start condition P = Stop condition Sr = Repeated Start condition R = Read (SDA released high) W = Write (SDA held low) Figure 5-25: I²C bus activity notation 5.14.1.
RX62N Group, RX621 Group 1) 5. Usage Examples Configuration and transmission The MCU’s I²C channel 1 will be configured for Master operation and used to send three bytes to a slave. S Slave address W A Memory address A Data A Data A Data A P Figure 5-26: The bus activity, showing 4 bytes being transmitted to the EEPROM /* Peripheral driver function prototypes */ #include "r_pdl_iic.h" #include "r_pdl_cgc.h" #include "r_pdl_intc.h" #include "r_pdl_cmt.
RX62N Group, RX621 Group 5.
RX62N Group, RX621 Group 2) 5. Usage Examples Reception I²C channel 1 will be configured for Master operation and used to read four bytes from a slave device.
RX62N Group, RX621 Group 3) 5. Usage Examples Repeated Start I²C channel 1 will be configured for Master operation. The memory address pointer of an EEPROM will be modified, and then a Repeat Start condition used to change to read the byte at that memory location in the EEPROM.
RX62N Group, RX621 Group 5. Usage Examples 5.14.2. Master mode with DMAC In the following example, data is written to an EEPROM in two bursts. DMAC channel 3 is used to handle the data transfer. The same EEPROM address locations are then read out in two bursts. DMAC channel 2 is used to handle the data transfer. /* Peripheral driver function prototypes */ #include "r_pdl_iic.h" #include "r_pdl_cgc.h" #include "r_pdl_cmt.h" #include "r_pdl_dmac.
RX62N Group, RX621 Group 5. Usage Examples /* Set up a DMAC channel for IIC reception */ R_DMAC_Create( 2, PDL_DMAC_NORMAL | PDL_DMAC_SIZE_8 | PDL_DMAC_SOURCE_ADDRESS_FIXED | PDL_DMAC_DESTINATION_ADDRESS_PLUS | PDL_DMAC_IRQ_END, PDL_DMAC_TRIGGER_IIC0_RX, (uint8_t *)&RIIC0.
RX62N Group, RX621 Group 5.
RX62N Group, RX621 Group 5.
RX62N Group, RX621 Group 5. Usage Examples 5.14.3. Master mode with DTC In the following example, data is written to an EEPROM in two bursts. The DTC is used to handle the data transfer. The same EEPROM address locations are then read out in two bursts. The DTC is used to handle the data transfer. /* Peripheral driver function prototypes */ #include "r_pdl_iic.h" #include "r_pdl_cgc.h" #include "r_pdl_cmt.h" #include "r_pdl_dtc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 5. Usage Examples eeprom_data_array_1, (uint8_t *)&RIIC0.ICDRT, 6, PDL_NO_DATA ); /* Set up a DTC channel for IIC reception */ R_DTC_Create( PDL_DTC_NORMAL | \ PDL_DTC_SOURCE_ADDRESS_FIXED | PDL_DTC_DESTINATION_ADDRESS_PLUS | \ PDL_DTC_SIZE_8 | \ PDL_DTC_IRQ_COMPLETE | \ PDL_DTC_TRIGGER_ICRXI0, dtc_iic0_rx_transfer_data, (uint8_t *)&RIIC0.
RX62N Group, RX621 Group 5.
RX62N Group, RX621 Group 5.
RX62N Group, RX621 Group 5. Usage Examples 5.14.4. Slave mode In this example the MCU behaves as a virtual slave memory device on channel 0. It will respond to 7-bit address 0001001b. The sample is interrupt driven after the initial setup. /* Peripheral driver function prototypes */ #include "r_pdl_iic.h" #include "r_pdl_cgc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 5. Usage Examples /* Read the status */ R_IIC_GetStatus( SLAVE_CHANNEL, &status_flags, &tx_count, &rx_count ); /* Has the master just completed a write? */ if(rx_count != 0) { StoreData(rx_count); /*Start monitoring again.*/ bStartMonitor = true; } /* Has the master just completed a read? */ else if(tx_count != 0) { /*Increment the current index by the amount the master read*/ data_storage_index += tx_count; /*Start monitoring again.
RX62N Group, RX621 Group 5. Usage Examples /* Store any data */ while(count != 0) { data_storage[data_storage_index] = Rx_Buffer[index]; count--; index++; data_storage_index++; if(data_storage_index == STORAGE_SIZE) { /* Wrap around */ data_storage_index = 0; } } } Figure 5-34: Virtual IIC Slave memory R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 5.15. 5. Usage Examples Serial Peripheral Interface 5.15.1. Using one slave (1) This is an example of Serial Peripheral Interface usage where one SPI master communicates with one SPI slave. The RSK evaluation board is used to connect the two SPI channels together.
RX62N Group, RX621 Group 5.
RX62N Group, RX621 Group 5.
RX62N Group, RX621 Group 5. Usage Examples 5.15.2. Using one slave (2) Figure 5-36 shows how strings of 8-bit data are copied into 32-bit buffers, then transmitted and received simultaneously by the master and slave. The received data is then checked to confirm that the transfer was successful. /* Peripheral driver function prototypes */ #include "r_pdl_cgc.h" #include "r_pdl_spi.h" /* PDL device-specific definitions */ #include "r_pdl_definitions.h" /* Required for this example */ #include
RX62N Group, RX621 Group 5.
RX62N Group, RX621 Group 5. Usage Examples void spi_slave_callback(void) { uint16_t StatusValue = 0; uint16_t Sequence_count; /* Read the slave channel status */ R_SPI_GetStatus( SLAVE_CHANNEL, &StatusValue, &Sequence_count ); /* No errors? */ if ((StatusValue & 0x000Du) == 0x0u) { slave_transfer_complete = true; } else { while(1); } } Figure 5-36: Example of Serial Peripheral Interface use R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 5. Usage Examples 5.15.3. Master operation with multiple slaves This is an example of Serial Peripheral Interface usage where one SPI master communicates with four SPI slaves. Each slave requires different data bit lengths.
RX62N Group, RX621 Group 5.
RX62N Group, RX621 Group 5. Usage Examples 0 ); } Figure 5-37: Example of multiple slave Serial Peripheral Interface use R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 5.16. 5. Usage Examples 10-bit Analog to Digital Converter 5.16.1. ADC Conversion Figure 5-38 shows an example of ADC usage. ADC unit 0 is polled until the conversion is complete. Interrupts are enabled for ADC unit 1, which operates in the one-cycle scan mode. /* Peripheral driver function prototypes */ #include "r_pdl_adc_10.h" #include "r_pdl_cgc.h" #include "r_pdl_intc.h" /* RPDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 5. Usage Examples /* Shutdown unit 2 */ R_ADC_10_Destroy( 0 ); } void ADC1Handler(void) { R_ADC_10_Read( 1, adc1_result ); } Figure 5-38: Example of ADC Conversion R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 5. Usage Examples 5.16.2. ADC Self-Diagnostic function Figure 5-39 shows a usage example of ADC Self-Diagnostic function. ADC unit 0 is set to get the A/D conversion of Vref x 1 voltage value. ADC unit 1 is set to get the A/D conversion of Vref x 0 voltage value. /* PDL functions */ #include "r_pdl_adc_10.h" #include "r_pdl_cgc.h" #include "r_pdl_intc.h" /* PDL device-specific definitions */ #include "r_pdl_definitions.
RX62N Group, RX621 Group 5. Usage Examples /* Fetch the result */ R_ADC_10_Read( 0, &result_adc0 ); /* Shutdown ADC unit 0 */ R_ADC_10_Destroy(0); } void ADC0_callback(void) { adc0_complete = true; } Figure 5-39: Example of ADC Self-Diagnostic function R20UT0084EE0112 Rev.1.12 July.
RX62N Group, RX621 Group 6. RX-specific notes 6. RX-specific notes 6.1. Interrupts and processor mode The RX CPU has two processor modes; supervisor and user. The API driver functions will be executed by the CPU in user mode. However, any callback functions which are called by the API interrupt handlers will be executed by the CPU in supervisor mode.
RX62N Group, RX621 Group Revision History Revision History RX62N Group User’s Manual Description Rev. Date Page Summary 0.01 May 27, 2010 First draft. 0.02 Jun 22, 2010 Re-designed the I/O parameters; Modified DMAC, DTC, PPG, SCI and CRC functions. 0.03 Jul. 23, 2010 Modified CGC, IO_PORT, DTC, MTU, TMR and CMT. Improved ADC and DAC comments. Modified INTC, BSC, DTC, MTU, SCI and IIC. Created SPI. 0.04 Aug. 25, 2010 Added an SDRAM bus control example. 0.05 0.06 Sep.
RX62N Group, RX621 Group Revision History Description Rev. 1.00 Date Jan. 12, 2011. Page Summary 4-212 Added a remark. 4-220 Added more detail to ADC_10_Create parameter data3. 4-221 Added columns for 48 and 12 MHz; Added a remark for simultaneous ADC and DAC use. 5-4 Updated the R_IO_PORT_Set examples. 5-6 Added an LVD usage example. 5-29 Added an RTC usage example. 5-31 Added an IWDT usage example. 5-63 Added SPI usage examples. 5-72 Correction of ADC_10 sample code.
RX62N Group, RX621 Group Revision History Description Rev. Date Page Summary 1-11 Added the section on build options. 2-16 Removed watchdog references from RTC description. 2-25 Removed linked operation configuration from DAC description. 4-4 Added a comment regarding function macros. 4-8 Corrected name of R_CGC_GetStatus in example. 4-12 Text changes in the Module column. 4-16 Added support for access exceptions. 4-67 Added type casts to parameters in example.
RX62N Group, RX621 Group Revision History Description Rev. Date Page Summary 4-170 to Moved "Data transfer format" options out of the smart-card-only section. 4-171 This option is now available to all modes. 4-172 R_SCI_Create: Modified the description for data3. Updated the remarks. 4-177 to Added continuous receive mode parameters and remark. 4-178 4-190 R_IIC_Create: Updated remarks. 4-193 R_IIC_MasterSend : Corrected the maximum interrupt priority level.
Renesas Peripheral Driver Library User’s Manual RX62N, RX621 Group Publication Date: Rev.1.00 Rev.1.01 Rev.1.02 Rev.1.03 Rev.1.04 Rev.1.10 Rev.1.11 Rev.1.
http://www.renesas.com SALES OFFICES Refer to "http://www.renesas.com/" for the latest and detailed information. Renesas Electronics America Inc. 2801 Scott Boulevard Santa Clara, CA 95050-2549, U.S.A. Tel: +1-408-588-6000, Fax: +1-408-588-6130 Renesas Electronics Canada Limited 1101 Nicholson Road, Newmarket, Ontario L3Y 9C3, Canada Tel: +1-905-898-5441, Fax: +1-905-898-3220 Renesas Electronics Europe Limited Dukes Meadow, Millboard Road, Bourne End, Buckinghamshire, SL8 5FH, U.
RX62N, RX621 Group R20UT0084EE0112