Using an SPI interface, I need to communicate the RC522 RFID reader with the Renesas R5F100LE board. While communicating, I couldn't read the Device ID. Could you please explain the configuration settings in the e2studio?
To perform SPI interface in Renesas, follow the below steps:
Configure the SPI interface: Configure the SPI interface using the SPI registers.
Set the SPI clock rate: Set the SPI clock rate based on the device specifications.
Enable the SPI interface: Enable the SPI interface by setting the appropriate bit in the control register.
Transmit data: Write data to the SPI data register.
Receive data: Read data from the SPI data register.
Disable the SPI interface: Disable the SPI interface by clearing the appropriate bit in the control register.
Repeat the process: Repeat the process for transmitting and receiving data in a loop.
These steps will help you perform SPI interface in Renesas. UPSer
Thanks for reaching out to RL78 forum.
On Code Generator->Serial configure these settings for SPI (It is called CSI but it is basically the same):
For channel CSI00 you can configure the following settings according to your application:
All the related APIs can be found in r_cg_serial.c file.
You can take a look on the attached example also.
Serial Array Unit for 3-Wire Serial IO.rar
The configuration I have done is below.
P1_bit.no3 = 0; //slave select R_CSI00_Send_Receive(&SendData, 2, &rx_bits);
P1_bit.no3 = 1;
Having issues on the receiving end. While probing we get signals at both ends. But no information is received in the receive buffer. If we add a delay after the SPI SendReceive function we get the data.
Can you please let me know why this happens?
This probably happens because after you send the data, the slave select line goes to 0 and the slave cannot receive any data. By adding a delay you solve this issue as the data have enough time to arrive. But this is not the best way to this. The recommended way is to get notified when the transfer has been completed.
I would suggest that you use single transfer mode, so that you get an interrupt when the requested number of bytes have been sent. Please take a look on the attached project that uses 'send_end_flag' defined in r_cg_serial_user.c and set to 1 by r_csi00_callback_sendend.
Hope it helps.
Were you able to set up the SPI communication ?
Thank you, It works.