YRSPSH7267-1030 Renesas Starter Kit2+ for SH7267 RPDL Manual RENESAS SINGLE-CHIP MICROCOMPUTER SuperH RISC Engine
Rev. 1.00 May 22 2012 Renesas Electronics America www.renesas.
Table of Contents 1. Introduction............................................................................................................................................... . 1-1 1.1. Using the library within your project ......................................................................................................... 1-2 1.1.1. Copy the files ................................................................................................................................... 1-2 1.1.2.
Rev. 1.00 May 22 2012 Renesas Electronics America www.renesas.
1) 2) 3) 4.2.5. 1) 2) 3) 4) 5) 4.2.6. 1) 2) 3) 4) 4.2.7. 1) 2) 3) 4) 4.2.8. 1) 2) 3) 4) 4.2.9. 1) 2) 3) 4) 5) 6) 4.2.10. 1) 2) 3) 4) 5. R_PFC_Read ................................................................................................................................... 4-42 R_PFC_Write................................................................................................................................... 4-44 R_PFC_Modify...................................................................
1. Introduction The Renesas Peripheral Driver Library (PDL) is a unified API for controlling the peripheral modules on the microcontrollers made by Renesas Technology.
1.1. 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. 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) Copy the required header and library files to a suitable location. b) Include the required header files.
1.3.
Driver 2 2.1 Overview 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 Function This library has the following control functions available as a peripheral driver. (1) Serial Communication Interface These driver functions are used to configure the serial channels and manage the transmission and / or reception of data across them.
Driver 2. 2.3. 2.2 8BControl Function Serial Communication Interface Driver The driver functions support the use of the eight serial communication channels, providing the following operations. 1. Configuration for use, including a. Automatic baud rate clock calculations b. Automatic interrupt control c. Automatic I/O pin configuration 2. Disabling channels that are no longer required and enabling low-power mode. 3. Transmitting data, with polling or interrupt mode automatically selected. 4.
Driver 2. 2.4. 2.2 8BControl Function I/O Port Driver The driver functions support the use of the 115 I/O port pins, providing the following operations. 1. Configuration for use. 2. Reading a pin or 16-bit port value. 3. Writing to a pin or 16-bit port. 4. Comparing a pin or 16-bit port with a supplied value. 5. Modifying a pin or 16-bit port using a logical operation. 6. Waiting until a pin or 16-bit port matches a supplied value. Rev.1.
Driver 2. 2.5. 2.2 8BControl Function 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. Rev.1.
Driver 2. 2.6. 2.2 8BControl Function 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. Controlling an external interrupt input. 3. Reading the status of an external interrupt. 4. Assigning handlers for the fixed exception interrupts. 5. Reading the current CPU interrupt priority level. 6. Changing the CPU interrupt priority level. Rev.1.
Driver 2. 2.7. 2.2 8BControl Function Analog to Digital Converter Driver The driver functions support the use of the 8 ADC channels, providing the following operations. 1. Configuration for use, including a. Automatic clock setting using sampling time as an input. b. Automatic interrupt control c. Automatic I/O pin configuration 2. Disabling units that are no longer required and enabling low-power mode. 3. Control of one or more channels (depending upon the selected mode) 4.
Driver 2. 2.8. 2.2 8BControl Function Clock Pulse Generator 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 bus clock output pin. Rev.1.
Driver 2. 2.9. 2.2 8BControl Function 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 a. Automatic clock setting using frequency or period as an input. b. Automatic interrupt control 2. Disabling channels that are no longer required and enabling low-power mode. 3. Control of a timer, including change of frequency. Rev.1.
Driver 2. 2.2 8BControl Function 2.10. Multi Function Timer Pulse Unit 2 Driver The driver functions support the use of the five MTU2 channels, providing the following operations. 1. Configuration for use, including a. Access to all control bits. b. Automatic interrupt control c. Automatic I/O pin configuration 2. Disabling channels that are no longer required and enabling low-power mode. 3. Control of a timer. 4. Reading the status and registers of a timer. Rev.1.
Driver 2. 2.2 8BControl Function 2.11. Bus State Controller Driver The driver functions support the control of the external bus, providing the following operations. 1. Configuration of the seven address space areas 2. Configuration of the error handling functions. 3. Disabling an area that is not required. Rev.1.
Driver 2. 2.2 8BControl Function 2.12. 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 a. Access to all control bits. b. Automatic interrupt control 2. Disabling DMA channels that are no longer required and enabling low-power mode. 3. Control of one or more channels. 4. Reading the status and operation registers of a channel. Rev.1.
3 Standard Type 3. Standard Types This chapter describes the data types used in this library. For details about the setting values, refer to the section “4.2 Description of Each API”. Table 1: Data types Type bool float uint8_t uint16_t uint32_t Defined in typdefine.h C typedefine.h Rev.1.
Library Reference 4 4 4.2 Description of Each API 4.1 API List by Peripheral Function 4. Library Reference 4.1. API List by Peripheral Function Table 4.1 lists the Renesas Embedded APIs by peripheral function. Table 4.1 Renesas Embedded API List Category Clock Pulse Generator Interrupt controller I/O port Port Function Control Bus Controller DMA Controller Multi functional Timer Unit Compare Match Timer Serial Communication Interface 10-bit Analog to Digital converter Rev.1.
Library Reference 4 4.2 Description of Each API 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 Prototype Description Return value Summarises processing by the API function. The function format and a brief explanation of the arguments. Explains how to use the API function and shows assignable parameters separating each argument with [argument].
Library Reference 4 4.2.1 4.2.1. 1) 32BClock Pulse Generator R_CPG_Set Clock Pulse Generator R_CPG_Set Synopsis Configure the clock pulse generator Prototype bool R_CPG_Set ( uint32_t data1, // Input frequency uint32_t data2, // System clock frequency uint32_t data3, // Peripheral clock frequency uint8_t data4, // Clock mode settings uint8_t data5 // Configuration options ); Description Set the clock output frequencies and options. [data1] The frequency of the main clock oscillator in Hertz.
Library Reference 4 4.2.1 32BClock Pulse Generator R_CPG_Set Program example /* PDL definitions */ #include “r_pdl_cpg.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.h” void func(void) { /* Configure operation using a 18 MHz input clock */ /* ICLK = 144 MHz, PCLK = 36 MHz, BCLK = 72 MHz */ R_CPG_Set (18E6, 144E6, 36E6, PDL_CPG_CK_2, PDL_CPG_OUT_CK_01); } Rev.1.
Library Reference 4 4.2.2 33BInterrupt Control Unit R_INTC_CreateExtInterrupt 4.2.2. 1) Interrupt Control Unit R_INTC_CreateExtInterrupt Synopsis Configure an external interrupt pin. Prototype bool R_INTC_CreateExtInterrupt( uint8_t data1, // Interrupt selection uint16_t data2, // Configuration uint8_t data3, // Interrupt priority level // Callback function void * func ); Description Sets the specified external interrupt. [data1] Choose the interrupt pin to be configured.
Library Reference 4 4.2.2 33BInterrupt Control Unit R_INTC_CreateExtInterrupt [func] The function to be called when a valid condition is detected. Specify PDL_NA if no IRQn interrupt is required. A function must be specified for the NMI pin. [data3] The IRQn interrupt priority level. Select between 0 (interrupt disabled) and 15 (highest priority). This value does not apply to the NMI pin and is ignored. Return value True if all parameters are valid and exclusive; otherwise false.
Library Reference 4 4.2.2 33BInterrupt Control Unit R_INTC_CreateExtInterrupt Remarks (2/2) • Please see the notes on callback function use • The NMI callback function should not return. It should stop operation or reset the system. Program example #include “r_pdl_intc.h” /* Declaration of callback function */ void CallBackFunc( void ); void func( void ) { /* Configure the IRQ0 interrupt on pin IRQ1-A */ R_INTC_CreateExtInterrupt( PDL_INTC_IRQ1, PDL_INTC_IRQ_FALLING | 7, CallBackFunc ); } Rev.1.
Library Reference 4 2) 4.2.2 33BInterrupt Control Unit R_INTC_CreateExceptionHandlers R_INTC_CreateExceptionHandlers Synopsis Assign handlers for the fixed-vector interrupts. Prototype bool R_INTC_CreateExceptionHandlers( // Array of Callback function void (* func())[9], ); Description Register the user functions to be called by the fixed-vector interrupts.
Library Reference 4 3) 4.2.2 33BInterrupt Control Unit R_INTC_ControlExtInterrupt R_INTC_ControlExtInterrupt Synopsis External interrupt control. Prototype bool R_INTC_ControlExtInterrupt( uint8_t data1, // Pin selection uint16_t data2 // Control ); Description Enables or disables the specified external interrupt. [data1] Choose the interrupt pin to be configured.
Library Reference 4 4.2.2 33BInterrupt Control Unit Remarks Rev.1.00 May 22 2012 REJ09B0566 R_INTC_ControlExtInterrupt • The NMI pin was enabled during R_INTC_CreateExtInterrupt and cannot be disabled (an MCU design feature). • When disabling an IRQn pin, the Interrupt Request flag will be cleared automatically. A callback function may be called once more if a valid event occurs just before the interrupt pin is disabled.
Library Reference 4 4.2.2 33BInterrupt Control Unit R_INTC_ControlExtInterrupt Program example #include "r_pdl_intc.h" void func( void ) { /* Disable the IRQ1 interrupt pin and clear the flag */ R_INTC_ControlExtInterrupt( PDL_INTC_IRQ1, PDL_INTC_R_INTC_DISABLE ); } Rev.1.
Library Reference 4 4) 4.2.2 R_INTC_GetExtInterruptStatus 33BInterrupt Control Unit R_INTC_GetExtInterruptStatus Synopsis Read the external interrupt status. Prototype bool R_INTC_GetExtInterruptStatus( uint8_t data1, // Pin selection // A pointer to the buffer where the status data shall be stored. uint8_t * data2 ); Description Acquire the status for the specified external interrupt. [data1] Choose the interrupt pin to be checked.
4 Library Reference 4.2.2 33BInterrupt Control Unit R_INTC_GetExtInterruptStatus Program example #include "r_pdl_intc.h" void func( void ) { uint8_t irq_status; /* Read the IR flags and pin states for IRQ5 */ R_INTC_GetExtInterruptStatus( PDL_INTC_IRQ5, &irq_status ); } Rev.1.
Library Reference 4 5) 4.2.2 33BInterrupt Control Unit R_INTC_Read R_INTC_Read Synopsis Read an interrupt register. Prototype bool R_INTC_Read( uint8_t data1, uint8_t data2, uint8_t * data3 ); Description // Register selection // Register number // Data storage location Read an interrupt register and store the value.
Library Reference 4 6) 4.2.2 33BInterrupt Control Unit R_INTC_Write R_INTC_Write Synopsis Update an interrupt register. Prototype bool R_INTC_Write( uint8_t data1, // Register selection uint8_t data2, // Register number uint8_t data3 // Register value ); Description Write the new value to an interrupt register. [data1] • The register to be updated.
Library Reference 4 7) 4.2.2 33BInterrupt Control Unit R_INTC_Modify R_INTC_Modify Synopsis Modify an interrupt register. Prototype bool R_INTC_Modify( uint8_t data1, // Register selection uint8_t data2, // number uint8_t data3, // Modification value // Logical operation uint8_t data4 ); Description Write the new value to the IPL bits in the Processor Status Word register. [data1] • The register to be updated.
Library Reference 4 4.2.2 33BInterrupt Control Unit R_INTC_Modify /* PDL definitions */ #include “r_pdl_intc.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.h” void func( void ) { /* Set bits 6 and 4 in IER09 to 1 */ R_INTC_Modify( PDL_INTC_REG_IER, 0x09, 0x50, PDL_INTC_OR ); } Rev.1.
Library Reference 4 4.2.3 34BI/O Port 4.2.3. 1) R_IO_PORT_Set I/O Port R_IO_PORT_Set Synopsis Configure an I/O port. Prototype bool R_IO_PORT_Set( uint32_t data1, // Port or port pin selection uint16_t data2, // Data direction value // CMOS output to be controlled uint16_t data3, ); Description (1/3) Sets the operating conditions of an I/O port or I/O port pin. [data1] Use either one of the following definition values to select the I/O port.
Library Reference 4 4.2.
Library Reference 4 4.2.3 34BI/O Port R_IO_PORT_Set Program example /* PDL definitions */ #include “r_pdl_io_port.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.h” void func(void) { /* Set the control registers for port D1 */ R_IO_PORT_Set( PDL_IO_PORT_D, 0xAA, 0x00 ); /* Set up port PB03 as an input port */ R_IO_PORT_Set( PDL_IO_PORT_B_3, PDL_IO_PORT_INPUT, 0 ); } Rev.1.
Library Reference 4 2) 4.2.3 34BI/O Port R_IO_PORT_Read R_IO_PORT_Read Synopsis Read data from an I/O port. Prototype bool R_IO_PORT_Read ( uint32_t data1, // Port or port pin selection uint16_t * data3 // Pointer to the variable in which the value shall be stored. ); Description (1/2) Gets the value of an I/O port or I/O port pin. [data1] Use either one of the following definition values to select the I/O port.
Library Reference 4 4.2.
Library Reference 4 4.2.3 34BI/O Port R_IO_PORT_Read Program example #include "r_pdl_io_port.h" void func( void ) { uint16_t data; /* Get the value of port E */ R_IO_PORT_Read(PDL_IO_PORT_E, &data); /* Get the value of port F2 */ R_IO_PORT_Read(PDL_IO_PORT_F_2, &data); } Rev.1.
Library Reference 4 3) 4.2.3 34BI/O Port R_IO_PORT_Write R_IO_PORT_ReadControl Synopsis Read an I/O port’s control registers. Prototype bool R_IO_PORT_ReadControl ( uint32_t data1, // Port or port pin selection uint16_t * data3 // Pointer to the variable in which the data direction value shall be stored. ); Description (1/2) Gets the value of an I/O port or I/O port pin. [data1] Use either one of the following definition values to select the I/O port.
Library Reference 4 4.2.
Library Reference 4 4.2.3 34BI/O Port R_IO_PORT_Write Program example #include "r_pdl_io_port.h" void func( void ) { uint16_t data; /* Get the direction of port E */ R_IO_PORT_ReadControl(PDL_IO_PORT_E, &direction); /* Get the direction of port F2 */ R_IO_PORT_Read(PDL_IO_PORT_F_2, &direction); } Rev.1.
Library Reference 4 4) 4.2.3 34BI/O Port R_IO_PORT_Write R_IO_PORT_Write Synopsis Write data to an I/O port. Prototype bool R_IO_PORT_Write ( Uint32_t data1, // Port or port pin selection // The data to be written to the I/O port or port pin. Uint16_t data2 ); Description (1/2) Write data to an I/O port or I/O port pin. [data1] Use either one of the following definition values to select the I/O port.
Library Reference 4 4.2.
Library Reference 4 4.2.3 34BI/O Port R_IO_PORT_Write Program example #include "r_pdl_io_port.h" void func( void ) { Uint16_t data; /* Write 0xFF01 to value of port E */ R_IO_PORT_Write(PDL_IO_PORT_E, 0xFF01); /* Write 1 to the Port Pin D3 */ R_IO_PORT_Write(PDL_IO_PORT_D_2, 0x1); } Rev.1.
Library Reference 4 5) 4.2.3 34BI/O Port R_IO_PORT_Compare R_IO_PORT_Compare Synopsis Check the pin states on an I/O port. Prototype bool R_IO_PORT_Compare ( uint32_t data1, // Input port or port pin selection uint16_t data2, // Modification value // Function pointer void * func ); Description (1/2) 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 to select the I/O port.
Library Reference 4 4.2.
Library Reference 4 4.2.3 34BI/O Port R_IO_PORT_Compare Program example /* PDL definitions */ #include “r_pdl_io_port.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.h” void IoHandler1{} void IoHandler2{} void func( void ) { /* Call function IoHandler1 if port pin PC5 is high */ R_IO_PORT_ Compare( PDL_IO_PORT_C_5, 1, IoHandler1 ); /* Call function IoHandler2 if port G reads as 0x5501 */ R_IO_PORT_Compare(PDL_IO_PORT_GH, 0x5501, IoHandler2 ); } Rev.1.
Library Reference 4 6) 4.2.3 34BI/O Port R_IO_PORT_Modify R_IO_PORT_Modify Synopsis Modify the pin states on an I/O port. Prototype bool R_IO_PORT_Modify( uint32_t data1, // Output port or port pin selection Uint8_t data2, // Logical operation // Modification value uint8_t data3 ); Description (1/2) 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 to select the I/O port.
Library Reference 4 4.2.
Library Reference 4 4.2.3 34BI/O Port R_IO_PORT_Modify Program example /* PDL definitions */ #include “r_pdl_io_port.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.h” void func( void ) { /* Invert port pin PE5 */ R_IO_PORT_Modify ( PDL_IO_PORT_E_5, 1, PDL_IO_PORT_XOR ); /* And the value port K with 0x0055 */ R_IO_PORT_Modify ( PDL_IO_PORT_K, 0x55, PDL_IO_PORT_AND ); } Rev.1.
Library Reference 4 7) 4.2.3 34BI/O Port R_IO_PORT_Modify R_IO_PORT_ModifyControl Synopsis Modify an I/O port’s control registers. Prototype bool R_IO_PORT_ModifyControl( uint32_t data1, // Output port or port pin selection Uint8_t data2, // logical operation selection uint8_t data3 // Modification value ); Description (1/2) Modifying the operation of an I/O port or I/O port pin. [data1] Use either one of the following definition values to select the I/O port.
Library Reference 4 4.2.
Library Reference 4 4.2.3 34BI/O Port R_IO_PORT_Modify Program example /* PDL definitions */ #include “r_pdl_io_port.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.h” void func( void ) { /* Set port pin PE5 */ R_IO_PORT_ModifyControl ( PDL_IO_PORT_E_5, PDL_IO_PORT_OR 1 ); /* Enable the lower 4 bits on port K to output */ R_IO_PORT_ModifyControl ( PDL_IO_PORT_K, PDL_IO_PORT_OR, 0x0F ); } Rev.1.
Library Reference 4 8) 4.2.3 34BI/O Port R_IO_PORT_Wait 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 // Comparison value uint8_t data2 ); Description (1/2) Loop until an I/O port or I/O port pin matches the comparison value. [data1] Use either one of the following definition values to select the I/O port.
Library Reference 4 4.2.
Library Reference 4 4.2.3 34BI/O Port R_IO_PORT_Wait Program example /* PDL definitions */ #include “r_pdl_io_port.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.h” void func( void ) { /* Wait until pin PC1 reads as 0 */ R_IO_PORT_Wait( PDL_IO_PORT_C_1, 0 ); /* Wait until port E reads as 0x0015 */ R_IO_PORT_Wait( PDL_IO_PORT_E, 0x0015 ); } Rev.1.
Library Reference 4 4.2.4 35BPort Function ControlR_PFC_Read 4.2.4. 1) Port Function Control R_PFC_Read Synopsis Read a PFC register. Prototype bool R_PFC_Read( Uint32_t data1, Uint16_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] Or use any of the following definition values to select the register.
Library Reference 4 4.2.4 35BPort Function ControlR_PFC_Read /* PDL definitions */ #include “r_pdl_pfc.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.h” void func( void ) { uint8_t data; /* Get the value of register PFC1 */ R_PFC_Read( 1, &data ); } Rev.1.
Library Reference 4 2) 4.2.4 35BPort Function ControlR_PFC_Modify R_PFC_Write Synopsis Write to a PFC register. Prototype bool R_PFC_Write( Uint32_t data1, Uint16_t data2 ); Description // PFC register selection // Data to be written to the PFC register Write the value to a PFC register. [data1] Or use any of the following definition values to select the register.
Library Reference 4 3) 4.2.4 35BPort Function ControlR_PFC_Read R_PFC_Modify Synopsis Modify a PFC register. bool R_PFC_Modify( Uint32_t data1, uint8_t data2, Uint16_t data3 ); Description // PFC register selection // Logical operation // Modification value Write the value to a PFC register. [data1] Or use any of the following definition values to select the register.
Library Reference 4 4.2.4 35BPort Function ControlR_PFC_Read /* PDL definitions */ #include “r_pdl_pfc.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.h” void func( void ) { /* Set bit 7 in PFC1 to 1 */ R_PFC_Modify( 1, PDL_PFC_OR, 0x80 ); } Rev.1.
Library Reference 4 4.2.5. 1) 4.2.5 36BBus State Controller R_BSC_Create Bus State Controller R_BSC_Create Synopsis Configure the external bus controller.
Library Reference 4 4.2.5 36BBus State Controller R_BSC_Create PDL_BSC_RD_WR_DISABLE PDL_BSC_RD_DISABLE PDL_BSC_ICIOWR_DISABLE PDL_BSC_ICIORD_DISABLE PDL_BSC_WE_DQMU_WE_DISABLE PDL_BSC_WE_DQML_DISABLE PDL_BSC_RAS_DISABLE PDL_BSC_CAS_DISABLE PDL_BSC_CKE_DISABLE PDL_BSC_WAIT_DISABLE PDL_BSC_BREQ_DISABLE PDL_BSC_BACK_DISABLE PDL_BSC_IOIS16_DISABLE Disable the Read/Write output of the BSC SDRAM signal. Disable the memory Read strobe signals for PCMCIA. Disable the IO Write cycles strobe signals for PCMCIA.
Library Reference 4 4.2.5 36BBus State Controller R_BSC_Create Program example /* PDL definitions */ #include “r_pdl_bsc.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.h” /* Bus error handler */ void BusErrorFunc(void){} void func(void) { /* create a space with SDRAM control register and SDRAM refresh rate control */ R_BSC_CreateAll(0,0,0, PDL_BSC_REFRESH_DIV_4_CLOCK | PDL_BSC_REFRESH_COUNTER |PDL_BSC_REFRESH_1_TIME, 0xa55a0046ul, BusErrorFunc, 2 ); } Rev.1.
3BLibrary Reference 4 2) 4.2.5 36BBus State Controller R_BSC_CreateArea R_BSC_CreateArea Synopsis Configure an external bus area.
3BLibrary Reference 4 4.2.
3BLibrary Reference 4 4.2.5 36BBus State Controller R_BSC_CreateArea Select the parameter that needs to be configured for the WCR register.
3BLibrary Reference 4 4.2.5 36BBus State Controller R_BSC_CreateArea [data14] The minimum number of wait cycles from issuing the ACTV command to issuing the READ (A)/WRIT (A) command (WTRCD). Valid between 0 and 3. [data15] Specify the CAS latency for area 3 (A3CL). Valid between 0 and 3. [data16] The number of minimum auto-precharge startup wait cycles (TRWL). Valid between 0 and 3. [data17] Number of Idle Cycles from REF Command/Self-Refresh Release to ACTV/REF/MRS Command (WTRC).
3BLibrary Reference 4 4.2.5 36BBus State Controller R_BSC_CreateArea Program example /* PDL definitions */ #include “r_pdl_bsc.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.h” void func(void) { /* Configure the CS0 Space for NORMAL module.
3BLibrary Reference 4 3) 4.2.5 36BBus State Controller R_BSC_Destroy R_BSC_Destroy Synopsis Stop the External Bus Controller. Prototype bool R_BSC_Destroy( // Area selection uint8_t data ); 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 • None. Program example #include “r_pdl_bsc.
3BLibrary Reference 4 4) 4.2.5 36BBus State Controller R_BSC_Destroy R_BSC_Control Synopsis Modify the External Bus Controller operation. Prototype bool R_BSC_Control( // Area selection uint8_t data ); Description Provide interrupt flag clearing [data] • Error clearing 0 Return value Clear the bus error signals. This will also clear the interrupt flag. True if all parameters are valid; otherwise false.
3BLibrary Reference 4 5) 4.2.5 36BBus State Controller R_BSC_GetStatus R_BSC_GetStatus Synopsis Read the External Bus Controller status flags. Prototype bool R_BSC_GetStatus( // A pointer to the data storage location uint8_t * data ); Description Read the interrupt status [data] The status flags shall be stored in the following format: b7 – b1 - Return value b0 0: Idle 1: Bus error condition detected True.
3BLibrary Reference 4 4.2.6 37BDMA Controller 4.2.6. R_DMAC_Create DMA Controller Note: The current RPDL demo sample code does not include RPDL API for DMAC. 1) R_DMAC_Create Synopsis Configure the DMA controller.
3BLibrary Reference 4 4.2.6 37BDMA Controller PDL_DMAC_DESTINATION_ADDRESS_RELOAD_DISABLE or PDL_DMAC_SOURCE_ADDRESS_RELOAD_ENABLE • DREQ signal type PDL_DMAC_DREQ_LOW_LEVEL or PDL_DMAC_DREQ_FALLING_EDGE or PDL_DMAC_DREQ_HIGH_LEVEL or PDL_DMAC_DREQ_RISING_EDGE R_DMAC_Create Disable or enable reloading of destination address. Select signal type at which DMA request is detected: low level, high level, rising edge or falling edge. [data3] Configure the start trigger for channel DMAn.
3BLibrary Reference 4 4.2.6 37BDMA Controller Description (2/3) R_DMAC_Create [data5] The start address of destination [data6] The number of bytes to be transferred. [data7] The reload address value of source. This value is ignored if the reload function is disabled. [data8] The reload address value of destination. This value is ignored if the reload function is disabled. [data9] The reload value for number of bytes. This value is ignored if the reload function is disabled.
3BLibrary Reference 4 2) 4.2.6 37BDMA Controller R_DMAC_Destroy R_DMAC_Destroy Synopsis Shutdown the DMA controller. Prototype bool R_DMAC_Destroy( // channel to be disabled uint8_t data1 ); Description Shutdown the DMAC module. [data1] The channel number n (where n = 0 to 15). Return value True if the shutdown succeeded; otherwise false. Category DMA controller Reference R_DMAC_Create, R_DMAC_Control Remarks • If all channels have been suspended, the DMAC module will be disabled.
3BLibrary Reference 4 3) 4.2.6 37BDMA Controller R_DMAC_Control R_DMAC_Control Synopsis Control the DMA controller. Prototype bool R_DMAC_Control ( uint8_t data1, // Channel number uint8_t data2, // Control options uint32_t data3, // Source reload address uint32_t data4, // Destination reload address // Transfer byte reload count uint32_t data5 ); Description Change the state of a DMA controller channel. [data1] Channel selection.
3BLibrary Reference 4 4.2.6 37BDMA Controller R_DMAC_Control Program example /* PDL definitions */ #include “r_pdl_dmac.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.h” void func(void) { /* Enable transfers on channel 2 */ R_DMAC_Control( PDL_DMAC_2, PDL_DMAC_ENABLE ); /* Suspend transfers on all enabled channels */ R_DMAC_Control( PDL_DMAC_ALL, PDL_DMAC_SUSPEND ); /* Allow all suspended channels to resume */ R_DMAC_Control( PDL_DMAC_ALL, PDL_DMAC_ENABLE ); } Rev.1.
Library Reference 4 4) 4.2.6 37BDMA Controller R_DMAC_GetStatus R_DMAC_GetStatus Synopsis Check the status of the DMA channel. Prototype bool R_DMAC_GetStatus( uint8_t data1, // Control options uint16_t * data2, // Status flags pointer uint32_t * data3, // Current source address pointer uint32_t * data4, // Current destination address pointer uint32_t * data5 // Current transfer byte count ); Description Return status flags and current channel registers.
Library Reference 4 4.2.6 37BDMA Controller R_DMAC_GetStatus Program example /* PDL definitions */ #include “r_pdl_dmac.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.h” void func(void) { uint16_t StatusValue; uint32_t SourceAddr; /* Read the status and current source address for channel 2 */ R_DMAC_GetStatus( 2, &StatusValue, &SourceAddr, PDL_NA, PDL_NA ); } Rev.1.
3BLibrary Reference 4 4.2.7 38BMulti Function Timer Pulse Unit 4.2.7. 1) R_MTU_Create Multi Function Timer Pulse Unit R_MTU_Create Synopsis Configure a Multi-function timer pulse unit channel.
3BLibrary Reference 4 4.2.7 38BMulti Function Timer Pulse Unit Description (2/5) R_MTU_Create [data3] Configure the counter operation. [data3] Configure the IO control registers. b0:b7 Timer I/O Control Register (TIORH_0, TIOR_1, TIOR_2, TIORH_3, TIORH_4) [data4] Configure the IO control registers. b0:b7 Timer I/O Control Register (TIORL_0, TIORL_3, TIORL_4) [data5] The register TCNT value. [data6] The register TGRA value. [data7] The register TGRB value.
3BLibrary Reference 4 4.2.7 38BMulti Function Timer Pulse Unit R_MTU_Create Program example /* PDL definitions */ #include “r_pdl_mtu.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.h” void func(void) { /* Configure MTU0: PCLK, clear after a compare match A */ R_MTU_Create( 0, 0, PDL_MTU_CLK_PCLK_DIV_1 | PDL_MTU_CLEAR_CM_A, 0, 0, 199, 99, 0, 0, 0, 0, 0, PDL_NO_FUNC, PDL_NO_FUNC, PDL_NO_FUNC, PDL_NO_FUNC, PDL_NO_FUNC, PDL_NO_FUNC, 0, PDL_NO_FUNC, PDL_NO_FUNC, 0 ); } Rev.1.
3BLibrary Reference 4 2) 4.2.7 38BMulti Function Timer Pulse Unit R_MTU_Destroy R_MTU_Destroy Synopsis Disable a timer channel. Prototype bool R_MTU_Destroy( // Channel selection uint8_t data ); Description Shut down an MTU channel. [data] The Multi-function timer pulse unit channel n (where n = 0, 1, 2, 3 or 4). Return value True if the channel selection is valid; otherwise false.
3BLibrary Reference 4 3) 4.2.7 38BMulti Function Timer Pulse Unit R_MTU_Control R_MTU_Control Synopsis Control a timer channel.
3BLibrary Reference 4 4.2.7 38BMulti Function Timer Pulse Unit Remarks Rev.1.00 May 22 2012 REJ09B0566 R_MTU_Control • None.
3BLibrary Reference 4 4.2.7 38BMulti Function Timer Pulse Unit R_MTU_Control Program example /* PDL definitions */ #include “r_pdl_mtu.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.h” void func(void) { /* Load the counter on channel MTU channel 0 */ R_MTU_Control( 0, PDL_MTU_COUNTER, 0xFFDD, 0, 0, 0, 0 ); } Rev.1.
Library Reference 4 4) 4.2.7 38BMulti Function Timer Pulse Unit R_MTU_Read R_MTU_Read Synopsis Read from timer channel registers.
Library Reference 4 4.2.7 38BMulti Function Timer Pulse Unit R_MTU_Read Program example /* PDL definitions */ #include “r_pdl_mtu.h” /* PDL 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 A and D for channel MTU0 */ R_MTU_Read( 0, &Flags, PDL_NA, &General_A, PDL_NA, PDL_NA, &General_D ); } Rev.1.
4 4.2.7 Multi Function Timer 4.2.8. 1) 3BLibrary Reference R_MTU_CreateChannel Compare Match Timer R_CMT_Create Synopsis Configure a CMT channel. Prototype bool R_CMT_Create( uint8_t data1, uint16_t data2, void * 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.
4 4.2.7 Multi Function Timer Remarks (2/2) 3BLibrary Reference R_MTU_CreateChannel • 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. • If the requested period is not a multiple of the minimum period, the actual time period will be more than the requested time period. Program example /* PDL definitions */ #include “r_pdl_cmt.
3BLibrary Reference 4 2) 4.2.7 Multi Function Timer Pulse Unit R_CMT_Destroy R_CMT_Destroy Synopsis Disable a CMT unit. Prototype bool R_CMT_Destroy( // Unit selection uint8_t data ); Description Shut down a CMT unit. [data] The timer unit n (where n = 0 or 1). Return value True if the unit selection is valid; otherwise false. Category Compare Match Timer Reference R_CMT_Create Remarks • The timer unit is put into the stop state to reduce power consumption.
3BLibrary Reference 4 3) 4.2.7 Multi Function Timer Pulse Unit R_CMT_Control R_CMT_Control Synopsis Control CMT operation. Prototype bool R_CMT_Control( uint8_t data1 // Channel selection uint16_t data2 // Configuration selection // Period, frequency or register data void * data3 ); 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.
Library Reference 4 4) 4.2.7 Multi Function Timer Pulse Unit R_CMT_Read 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).
Library Reference 4 4.2.9 40BSerial Communication Interface 4.2.9. 1) R_SCI_Create Serial Communication Interface R_SCI_Create Synopsis SCI channel setup. Prototype bool R_SCI_Create( uint8_t data1, uint32_t data2, uint32_t data3, uint8_t data4 uint8_t data5 ); Description (1/3) // Channel selection // Channel configuration // Bit rate or register value // Interrupt priority level //dma_channel Set up the selected SCI channel. [data1] Select channel SCIFn (where n = 0 to 7).
Library Reference 4 4.2.9 40BSerial Communication Interface Description (2/3) • Parity mode PDL_SCI_PARITY_NONE or PDL_SCI_PARITY_EVEN or PDL_SCI_PARITY_ODD • Stop bit length PDL_SCI_STOP_1 or PDL_SCI_STOP_2 R_SCI_Create No parity bit, even parity bit or odd parity bit. One or two stop bits. The option “PDL_SCI_8N1” can be used to select 8-bit data length, no parity and one stop bit.
Library Reference 4 4.2.9 40BSerial Communication Interface R_SCI_Create • This function configures each SCI pin that is required for operation. It also disables the alternative modes on those pins. • The wait time of 1 data bit period that is required during configuration is handled within this function. Program example /* PDL definitions */ #include “r_pdl_sci.h” /* PDL device-specific definitions */ #include "r_pdl_definitions.h" void func(void) { /* configure SCIF_3 in synchronous serial Mode.
Library Reference 4 2) 4.2.9 40BSerial Communication Interface R_SCI_Destroy R_SCI_Destroy Synopsis Shut down a SCI channel. Prototype bool R_SCI_Destroy( // Channel selection uint8_t data ); Description Stop data flow and shutdown the selected SCI channel. [data] Select channel SCIFn (where n = 0 to 7). Return value True if all parameters are valid; otherwise false. Category SCI Reference R_SCI_Create Remarks • The SCI channel is put into the power-down state.
4 3) Library Reference 4.2.9 40BSerial Communication Interface R_SCI_Send R_SCI_Send Synopsis Send a string of characters. Prototype bool R_SCI_Send( uint8_t data1, uint8_t data1, uint8_t * data2, uint8_t data3, void * func // Channel selection // DMA Channel selection // Pointer to transmit data // Channel configuration // Callback function ); Description Transmit characters on the specified serial channel. [data1] Select channel SCIFn (where n = 0 to 7).
Library Reference 4 4.2.9 40BSerial Communication Interface R_SCI_Send Program example /* PDL definitions */ #include “r_pdl_sci.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.h” void func( void ) { /* Send the Data from the SCIF_3 with polling base transmission */ R_SCI_Send( 3, 0, c_data, PDL_SCI_IDLE, PDL_NA ); } Rev.1.
Library Reference 4 4) 4.2.9 40BSerial Communication Interface R_SCI_Receive R_SCI_Receive Synopsis Receive a string of characters. Prototype bool R_SCI_Receive( uint8_t data1, uint8_t data1, uint8_t * data2, uint8_t data3, void * func1, void * func2( uint8_t ), void * func3 ); Description // Channel selection // DMA Channel selection // Receive buffer pointer // Receive threshold // Callback function // Callback function // Callback function Enable SCI reception and acquire any incoming data.
Library Reference 4 4.2.9 40BSerial Communication Interface Remarks (2/2) R_SCI_Receive • If callback function func1 is specified, callback functions are executed by the interrupt processing function. This means that no other interrupt can be processed until a callback function has completed. Program example /* PDL functions */ #include “r_pdl_sci.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.
Library Reference 4 5) 4.2.9 40BSerial Communication Interface R_SCI_Stop R_SCI_Stop Synopsis Terminate SCI transmission or reception. Prototype bool R_SCI_Stop( uint8_t data1, uint8_t data2 ); Description // Channel selection // Setup data 2 Stops SCI transmission or reception. [data1] Select channel SCIFn (where n = 0 to 7). [data2] • Select the process to be stopped. If multiple selections are required, use “|” to separate each selection. PDL_SCI_TX Stop the transmission process.
Library Reference 4 6) 4.2.9 40BSerial Communication Interface R_SCI_GetStatus R_SCI_GetStatus Synopsis Check the status of a SCI channel. Prototype bool R_SCI_GetStatus( uint8_t data1, uint8_t * data2, uint8_t * data3, uint8_t * data4 ); Description // Channel selection // Status flags // Characters transmitted // Characters received Acquires status of SCI transmission / reception. [data1] Select channel SCIFn (where n = 0 to 7).
Library Reference 4 4.2.10 41B10-bit Analog to Digital Converter R_ADC_10_Create 4.2.10. 10-bit Analog to Digital Converter 1) R_ADC_10_Create Synopsis Configure an ADC unit. Prototype bool R_ADC_10_Create( Uint16_t data1, // ADC configuration uint32_t data2, // ADC conversion clock frequency void * func, // Callback function // Interrupt priority level uint8_t data3 ); Description (1/2) Set the ADC’s mode and operating condition. [data1] Conversion options.
4 Library Reference 4.2.10 41B10-bit Analog to Digital Converter R_ADC_10_Create Single mode: AN6 PDL_ADC_10_CHANNELS_OPTION_7 Multi mode: AN4, AN5, AN6 Scan mode: AN0, AN1, AN2, AN3, AN4, AN5, AN6 Single mode: AN7 PDL_ADC_10_CHANNELS_OPTION_8 Multi mode: AN4, AN5, AN6, AN7 Scan mode: AN0, AN1, AN2, AN3, AN4, AN5, AN6, AN7 Rev.1.
Library Reference 4 4.2.10 41B10-bit Analog to Digital Converter Description (2/2) • Scan mode PDL_ADC_10_MODE_SINGLE or PDL_ADC_10_MODE_MULTI or PDL_ADC_10_MODE_SCAN • Trigger selection PDL_ADC_10_TRIGGER_SOFTWARE or PDL_ADC_10_TRIGGER_MTU_TRGAN or PDL_ADC_10_TRIGGER_MTU_TRG0N or PDL_ADC_10_TRIGGER_MTU_TRG4AN or PDL_ADC_10_TRIGGER_MTU_TRG4BN or PDL_ADC_10_TRIGGER_ADTRG R_ADC_10_Create Select single mode, multi mode or scan mode.
Library Reference 4 4.2.10 41B10-bit Analog to Digital Converter Remarks (2/2) R_ADC_10_Create • Interrupts are enabled automatically if a callback function is specified. • 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. Program example /* PDL definitions */ #include “r_pdl_adc_10.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.
Library Reference 4 2) 4.2.10 10-bit Analog to Digital Converter R_ADC_10_Destroy Synopsis Shut down an ADC unit. Prototype bool R_ADC_10_Destroy (); Description Return value Put the ADC into the Power-down state, with minimal power consumption. True ADC powered down successfully. Category ADC Reference R_ADC_10_Create Remarks • This function waits for the ADST flag to indicate that the converter has stopped.
Library Reference 4 3) 4.2.10 41B10-bit Analog to Digital Converter R_ADC_10_Control R_ADC_10_Control Synopsis Start or stop an ADC unit. Prototype bool R_ADC_10_Control( // ADC ON/OFF control uint16_t control ); Description Controls start / stop operation of the ADC. [data] Start or stop ADC operation. • On / off control PDL_ADC_10_ON or PDL_ADC_10_OFF Return value Start or stop ADC conversion for all channels. True if all parameters are valid; otherwise false.
4 4 4) 3BLibrary Reference 4.2.10 41B10-bit Analog to Digital Converter R_ADC_10_Read R_ADC_10_Read Synopsis Read the ADC conversion results. Prototype bool R_ADC_10_Read( // Pointer to the buffer where the converted values are to be stored uint16_t * data1 ); Description Reads the conversion values for an ADC channel. [data1] Specify a pointer to a variable or array where the results shall be stored. Return value True if a valid unit is selected; otherwise false.
5 4BUsage Examples 5. Usage Examples This chapter shows programming examples for each driver in this library.
4BUsage Examples 5 5.1. 5.1 21BInterrupt control 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. #include "r_pdl_io_port_library_SH7267.h" #include "r_pdl_intc_library_SH7267.
4BUsage Examples 5 5.
4BUsage Examples 5 5.3 23BBus Controller 5.2. I/O Port Figure 5-2 shows examples of I/O port configuration, reading and writing. /* PDL functions */ #include "r_pdl_io_port_library_SH7267.h" /* Following header file provides access to intrinsic functions useful for Configuring and controlling the interrupts. */ #include /* PDL device-specific definitions */ #include "r_pdl_definitions.
4BUsage Examples 5 5.3 23BBus Controller Figure 5-2 Example of I/O Port Operations 5.3. Bus Controller Figure 5-3 shows an example of external bus controller usage. /* PDL functions */ #include "r_pdl_bsc_library_SH7267.h" #include "r_pdl_pfc_library_SH7267.h" #include "r_pdl_cpg_library_SH7267.h" #include "r_pdl_io_port_library_SH7267.h" /* PDL device-specific definitions */ #include "r_pdl_definitions.
4BUsage Examples 5 5.3 23BBus Controller R_CPG_Set(18E6, 144E6, 36E6, PDL_CPG_CK_2, PDL_CPG_OUT_CK_01); /* Try external writes */ cs0_location_16_value = *cs0_location_16; *cs3_location_16 = 0x55AAu; /* Read the status flags */ R_BSC_GetStatus(&status); R_BSC_Control(0); while(1); } void BSC_error_handler(void) { /* Invert the port pin */ R_IO_PORT_Modify(PDL_IO_PORT_J_6,0,PDL_IO_PORT_XOR); /* Disable the refresh Interrupt */ R_BSC_Destroy(3); } Figure 5-3 Example of Bus Controller use 5-6 Rev.1.
4BUsage Examples 5 5.4. 5.4 24BDMA controller DMA controller Figure 5-4 shows an example of DMAC usage. Channel 0 will copy the string “Renesas SH7267” 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_cpg.h” #include “r_pdl_intc.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.
4BUsage Examples 5 5.
4BUsage Examples 5 5.4 24BDMA controller R_IO_PORT_Modify( PDL_IO_PORT_3_4, 1, PDL_IO_PORT_XOR ); /* Stop the DMAC */ R_DMAC_Destroy(); } Figure 5-4 Example of DMAC use 5-9 Rev.1.
4BUsage Examples 5 5.5. 5.5 25BMulti-Function Timer Pulse Unit Multi-Function Timer Pulse Unit 2 Figure 5-5 shows an example of MTU2 usage. /* Peripheral driver function prototypes */ #include “r_pdl_mtu.h” #include “r_pdl_cgc.h” #include “r_pdl_pfc.h” #include “r_pdl_intc.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.
4BUsage Examples 5 5.5 25BMulti-Function Timer Pulse Unit &General_D ); /* Modify channel 0 */ R_MTU_Control( 0, PDL_MTU_COUNTER, 0xFFDD, 0, 0, 0, 0 ); /* Shutdown channels 0 to 5 */ R_MTU_Destroy( 0 ); } Figure 5-5 Example of MTU2 use The counter is reset when it reaches 399. The 0 value is a valid state so the output toggle frequency is 50 MHz ÷ 400. FFFFh 399 199 Counter value 0 TIOCB0 TIOCA0 Figure 5-6 Example of MTU operation 5-11 Rev.1.
4BUsage Examples 5 5.6 26BCompare Match Timer 5.6. Compare Match Timer Figure 5-7 shows an example of Compare Match Timer usage. One channel is used to generate interrupts at regular intervals. /* PDL functions */ #include "r_pdl_cpg_library_SH7267.h" #include "r_pdl_pfc_library_SH7267.h" #include "r_pdl_io_port_library_SH7267.h" #include "r_pdl_cmt_library_SH7267.h" /* PDL device-specific definitions */ #include "r_pdl_definitions.
4BUsage Examples 5 5.6 26BCompare Match Timer { /* turn on the LED */ _check_Wr_Pin_H(PDL_IO_PORT_J_6,PDL_IO_PORT_HIGH); R_CMT_Control(0, PDL_CMT_STOP, 10E3); } Figure 5-7 Example of Compare Match Timer use 5-13 Rev.1.
4BUsage Examples 5 5.7. 5.7 Serial Communication Interface Serial Communication Interface (1) SCI Reception Figure 5-8 shows the setting of SCI channels 0 and 31 and the reception of data using interrupts (channel 0) 5-14 Rev.1.
4BUsage Examples 5 5.7 Serial Communication Interface /* The following 'r_pdl' header files define the API functions used in this file */ #include "r_pdl_definitions.h" /* The following 'r_pdl' header files define the SCI RPDL API functions prototypes*/ #include "r_pdl_sci_library_SH7267.h" /* The following 'r_pdl' header files define the CPG RPDL API functions prototypes*/ #include "r_pdl_cpg_library_SH7267.
4BUsage Examples 5 5.
4BUsage Examples 5 5.
4BUsage Examples 5 5.7 Serial Communication Interface (2) SCI Transmission Figure 5-9 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_cpg.h” #include “r_pdl_intc.h” /* PDL device-specific definitions */ #include “r_pdl_definitions.
4BUsage Examples 5 5.7 Serial Communication Interface “www.renesas.com”, PDL_SCI_IDLE, SCI3TxFunc ); /* Echo the character on channel 1 */ R_SCI_Send( 1, result, PDL_SCI_IDLE, PDL_NO_FUNC ); } /* SCI channel 3 transmit complete handler */ void SCI3TxFunc(void) { /* Shut down channel 3 */ R_SCI_Destroy( 3 ); } Figure 5-9 Example of SCI Transmission code 5-19 Rev.1.
4BUsage Examples 5 5.8 27BAnalog to Digital Converter 5.8. Analog to Digital Converter Figure 5-10 shows an example of ADC usage. Interrupt is enabled for ADC unit 0 channels 7, which operate in the single sample mode. /* PDL functions */ #include "r_pdl_adc_10_library_SH7267.h" #include "r_pdl_cpg_library_SH7267.h" /* PDL device-specific definitions */ #include "r_pdl_definitions.
4BUsage Examples 5 5.8 27BAnalog to Digital Converter } Figure 5-10 Example of ADC Conversion 5-21 Rev.1.
Revision History Rev. 1.0 Renesas Embedded Application Programming Interface User’s Manual Date Dec.17, 2009 Rev.1.