Page 1
APPLICATION NOTE RL78/G13 Handshake-based SPI Master Transmission/Reception Introduction This application note describes how the serial array unit (SAU) performs master transmission/reception by the simple SPI (CSI). The SAU uses the chip select (CS) signal to select a slave device and perform single transmission/reception.
RL78/G13 Handshake-based SPI Master Transmission/Reception 1. Specifications The serial array unit (SAU) described in this application note performs CSI master transmission/reception. for the slave device selected by the CS signal. The chip select (CS) signal uses the port.CS Handshake processing using the BUSY signal is also performed 1.1 Outline of CSI Communication...
RL78/G13 Handshake-based SPI Master Transmission/Reception 1.2 Outline of Communication In this application note, a command and communication for the command are performed at intervals of 1 ms. A set of a command and communication for the command is defined as a slot. Figure 1-2 shows an outline of slot processing and Table 1-1 lists the commands to be used.
Page 6
RL78/G13 Handshake-based SPI Master Transmission/Reception Figure 1-3 Timing chart for status check commands Slave Selection CS1 / CS2 BUSY SCK00 Status transmission SI00 from the slave SO00 00H: Status Confirmation FFH: Dummy FFH: Dummy INTCSI00 Send/receive Send/receive Send/receive completed completed...
RL78/G13 Handshake-based SPI Master Transmission/Reception 1.3 Communication Format Table 1-3 lists the characteristics of the CSI communication format that is used in the sample code. Table 1-3 Communication Format Item Specification Remarks Communication speed 1 Mbps About 200 kbps at minimum...
RL78/G13 Handshake-based SPI Master Transmission/Reception 1.5 Specification Details After completion of initialization, this sample code selects a slave, checks that slave’s status, and then transmits and receives data, switches slaves, and repeats the same operation. (1) Initialize the port. Use P52 controlling the CS1 signal as an output port to output a high-level signal.
Page 9
RL78/G13 Handshake-based SPI Master Transmission/Reception (4) After initialization is completed, the master performs communication with the slave as shown in the following steps. When the master is released from HALT mode by an INTTM03 interrupt, it issues the CS signal to The master waits in HALT mode for a 1-ms interval timer interrupt (INTTM03H).
Page 10
RL78/G13 Handshake-based SPI Master Transmission/Reception (6) Switching communication commands Receive, transmit, and transmit/receive commands can be switched by changing the comment-out lines in the r_main.c file. The transmit/receive command is set by default. R01AN6883EJ0100 Rev.1.00 Page 10 of 38 June.15.23...
Integrated development IAR Embedded Workbench for Renesas RL78 V4.21.2 from IAR environment (IAR) Systems Corp. C compiler (IAR) IAR C/C++ Compiler for Renesas RL78 V4.21.2.2420 from IAR Systems Corp. Board used RL78/G13 (R5F100LE) Target Board(QB-R5F100LE-TB) 3. Related Application Notes See also the following application notes, which are related to this application note: RL78/G13 Handshake-based SPI Slave Transmission/Reception (R01AN6884E) APPLICATION NOTE R01AN6883EJ0100 Rev.1.00...
RL78/G13 Handshake-based SPI Master Transmission/Reception 4. Hardware Descriptions 4.1 Example of Hardware Configuration Figure 4-1shows an example of the hardware configuration used in the application note. Figure 4-1 Hardware Configuration Master Slave1 RL78/G13 RESET RESET RL78/G13 BUSY P40/TOOL0 P137/INTP0 P10/SCK00...
RL78/G13 Handshake-based SPI Master Transmission/Reception 4.2 List of Pins to be Used Table 4-1 lists the pins to be used and their functions Table 4-1 Pins to be Used and Their Functions Pin Name Description P10/SCK00/SCL00/(TI07)/(TO07) Output Serial clock output pin...
RL78/G13 Handshake-based SPI Master Transmission/Reception 5. Description of the Software 5.1 List of Option Byte Settings Table 5-1 summarizes the settings of the option bytes. Table 5-1 Option Byte Settings Address Setting Value Description 000C0H 1110 1111B (EFH) Stops the watchdog timer operation.
RL78/G13 Handshake-based SPI Master Transmission/Reception 5.3 List of Variables Table 5-3 lists the global variables that are used in this sample code. Table 5-3 Global Variables Used in the Sample Code Type Variable Name Contents Function Used r_main.c uint8_t g_tx_data Buffer for transmit data r_main.c...
RL78/G13 Handshake-based SPI Master Transmission/Reception 5.4 List of Functions Table 5-4 lists the functions that are used in the sample code. Table 5-4 Functions Function Name Outline Source file R_Systeminit Initialization process r_systeminit.c R_CGC_Get_ResetSource Reset source reading r_cg_cgc_user.c R_CGC_Create CPU clock Configuration r_cg_cgc.c...
Page 17
RL78/G13 Handshake-based SPI Master Transmission/Reception [Function Name] R_CGC_Create Synopsis CPU clock Configuration Header r_cg_macrodriver.h r_cg_cgc.h r_cg_userdefine.h Declaration void R_CGC_Create (void) Explanation Set the CPU clock. Arguments • None Return value • None Remarks None [Function Name] R_PORT_Create Synopsis Port Configuration Header r_cg_macrodriver.h...
RL78/G13 Handshake-based SPI Master Transmission/Reception 5.6.3 CPU clock Configuration Figure 5-3 shows the flow of CPU clock Configuration. Figure 5-3 CPU clock Configuration R_CGC_Create() CMC resistor ← 00H : High-speed system clock, High-speed system clock / Subsystem MSTOP bit ← 1 Subsystem clock not used Clock Settings XTSTOP bit ←...
RL78/G13 Handshake-based SPI Master Transmission/Reception 5.6.5 SAU Configuration Figure 5-5 shows the flow of SAU Configuration. Figure 5-5 SAU Configuration R_SAU0_Create() SAU0EN ← 1 Clock supply to SAU0 SAU0 operation setting SPS0 ← 0000H ・Set the operating clock for SAU00...
RL78/G13 Handshake-based SPI Master Transmission/Reception 5.6.8 Flowchart of Main Processing Figure 5-8 to Figure 5-9 show the overall flow of processing in this application note. Figure 5-8 Main Processing 1/2 Main() User Main Initialization R_MAIN_UserInit() g_timeout_flag Clear timeout flag ← 0 Disable interrupts IE ←...
RL78/G13 Handshake-based SPI Master Transmission/Reception 5.6.12 CSI00 Transmit/Receive Processing Figure 5-13 shows the flow of CSI00 Transmit/Receive Processing. Figure 5-13 CSI00 Transmit/Receive Processing [Argument] *tx_buf: Transmit data R_CSI00_Send_Receive () tx_num: Number of transmit data *rx_buf: Receive data Initialize status flag...
RL78/G13 Handshake-based SPI Master Transmission/Reception 5.6.13 INICSI00 interrupt processing Figure 5-14 shows the flow of INICSI00 interrupt processing. Figure 5-14 INICSI00 interrupt processing R_CSI00_Interrupt () Set value of overrun detection flag in err_type Clear error flag Overrun error has occurred?
RL78/G13 Handshake-based SPI Master Transmission/Reception 5.6.14 Flowchart of CSI Status Check Figure 5-15 shows the flow of status checking. Figure 5-15 CSI Status Check CSI00_Status_check() cnt = 0 cnt <= 2 Is a return value from wait() 0? Enable interrupts...
RL78/G13 Handshake-based SPI Master Transmission/Reception 5.6.15 Flowchart of CSI Transmission/Reception Figure 5-16 shows the flow of transmission and reception. Figure 5-16 CSI Transmission/Reception CSI00_Send_Receive() Extract slave transmittable data count and set it in g_num g_num >= TX_RX_NUM g_rx_data_stored[1] >= TX_RX_NUM...
7. Reference Documents RL78/G13 User’s Manual: Hardware (R01UH0146J) RL78 family user's manual software (R01US0015) The latest versions can be downloaded from the Renesas Electronics website. Technical update The latest versions can be downloaded from the Renesas Electronics website. All trademarks and registered trademarks are the property of their respective owners.
Page 38
RL78/G13 Handshake-based SPI Master Transmission/Reception Revision History Description Rev. Date Page Summary 1.00 2023.6.15 First Edition R01AN6883EJ0100 Rev.1.00 Page 38 of 38 June.15.23...
Page 39
Unit Products The following usage notes are applicable to all Microprocessing unit and Microcontroller unit 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.
Page 40
Renesas Electronics disclaims any and all liability for any damages or losses incurred by you or any third parties arising from the use of any Renesas Electronics product that is inconsistent with any Renesas Electronics data sheet, user’s manual or other Renesas Electronics document.
Need help?
Do you have a question about the RL78/G13 and is the answer not in the manual?
Questions and answers