Master to Slave-
I am working on I2C communication with Renesas RX-130.In that communication I am using Rx130 as a slave.
During communication I get Address from master & get the acknowledgement from the slave.
there is no issue in slave reception.
Slave to Master-
During master reception get the acknowledgement from the master for read mode but
problem is Master not able to receive the data I didn't get the acknowledgement.
Please check attached code & waveform for your reference.
I am looking forward to solution hearing from you
Regards
AJ
/******************************************************************************* * DISCLAIMER * This software is supplied by Renesas Electronics Corporation and is only * intended for use with Renesas products. No other uses are authorized. This * software is owned by Renesas Electronics Corporation and is protected under * all applicable laws, including copyright laws. * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * Renesas reserves the right, without notice, to make changes to this software * and to discontinue the availability of this software. By using this software, * you agree to the additional terms and conditions found by accessing the * following link: * http://www.renesas.com/disclaimer * Copyright (C) 2017 Renesas Electronics Corporation. All rights reserved. *******************************************************************************/ /******************************************************************************* * File Name : main.c * Device(s) : RX231 * Tool-Chain : Renesas RX * Description : This is a simple slave demo of the RX231 RIIC for the RSKRX231 * starter kit (FIT module "r_riic_rx"). * Operation : 1. Compile and download the sample code. Click 'Reset Go' * to start the software. * Limitations : *******************************************************************************/ /******************************************************************************* * History : DD.MM.YYYY Version Description * 31.08.2017 1.00 First Release. *******************************************************************************/ /***************************************************************************** Includes <System Includes> , "Project Includes" ******************************************************************************/ //#include <stdio.h> #include "platform.h" #include "r_riic_rx_if.h" #include "r_riic_rx_config.h" #include "r_riic_rx_pin_config.h" /***************************************************************************** * Global definition ******************************************************************************/ /* Slave transfer Callback function */ static void salve_callback(void); void F_INT_1msDelay(void); void delay(void); void Frame_delay(void); #define F_INT (PORTE.PODR.BIT.B5) /* handler of RIIC Transfer */ static riic_info_t iic_info_s = {0}; /******************************************************************************* * Function Name: main * Description : main function of riic slavemode * Arguments : * Return Value : *******************************************************************************/ void main(void) { volatile riic_return_t ret; uint32_t version_id = 0; uint8_t slv_send_data[8] = {'R','e','n','e','s','a','s','\0'}; uint8_t slv_store_area[10] = {0x00}; ////////////////////////////////////////////////////////////// /* Sets IIC Information for Slave Transfer. */ iic_info_s.dev_sts = RIIC_NO_INIT; iic_info_s.ch_no = 0; iic_info_s.callbackfunc = &salve_callback; iic_info_s.cnt2nd = 10; iic_info_s.cnt1st = 7; iic_info_s.p_data2nd = slv_store_area; iic_info_s.p_data1st = slv_send_data; iic_info_s.p_slv_adr =(uint8_t*)FIT_NO_PTR; ///////////////////////////////////////////////////////////////////////// ret = R_RIIC_Open(&iic_info_s); if (RIIC_SUCCESS != ret) { printf("Open RIIC Failed,ret = %d\n",ret); return; } else { printf("Open RIIC success\n"); } /* Get RIIC Version ID */ version_id = R_RIIC_GetVersion(); printf("VersionId = version_id(V%d.%d)\n",((version_id >> 16) & 0x00FF), (version_id & 0x00FF)); F_INT_1msDelay(); delay(); ret = R_RIIC_SlaveTransfer(&iic_info_s); if (RIIC_SUCCESS != ret) { printf("slave transfer failed,ret = %d\n",ret); R_RIIC_Close(&iic_info_s); return; } else { /* start communication with Master */ while (1) { /* To determine whether the status is Finish */ if ((RIIC_FINISH != iic_info_s.dev_sts) && (RIIC_NACK != iic_info_s.dev_sts)) { /* To determine whether the status is TimeOut */ if (RIIC_TMO != iic_info_s.dev_sts) { /* waiting for dev status */ continue; } else { /* dev status is TimeOut */ printf("slave transfer is timeout\n"); break; } } else { /* Slave transfer is finish */ printf("Slave transfer is finish\n"); if(RIIC_FINISH == iic_info_s.dev_sts) { printf("receive data is %s\n",slv_store_area); } break; } } } do { /*Slave Transfer is Over */ ret = R_RIIC_Close(&iic_info_s); } while(RIIC_SUCCESS != ret); return; } /******************************************************************************* End of function main *******************************************************************************/ /******************************************************************************* * Function Name: salve_callback * Description : callback function function of riic slavemode * Arguments : * Return Value : *******************************************************************************/ static void salve_callback(void) { volatile riic_return_t ret; volatile riic_mcu_status_t iic_status; ret = R_RIIC_GetStatus(&iic_info_s,&iic_status); if(RIIC_SUCCESS != ret) { printf("Get I2c Status failed\n"); } else { printf("Get i2c status success,iic_status.LONG = %x\n",iic_status.LONG); } return; } void F_INT_1msDelay(void) { unsigned int i; F_INT=0; for(i=0;i<10000;i++); //delay 1.2ms F_INT=1; } void delay(void) { unsigned int i; for(i=0;i<60000;i++); //delay 7.5ms } void Frame_delay(void) { unsigned int i; for(i=0;i<3000;i++); //delay 0.376ms } /******************************************************************************* End of function salve_callback *******************************************************************************/
Hi AJ,
I noticed in the comments that the code is for the RX231. It's a little bit confusing as you said you're using RX130. Did you just copy the demo code to your project? In your slave code, what's the return value of the R_RIIC_SlaveTransfer() function? Did it successfully transferred the data? How about the master? What device are you using for the master?
JBIf this response, or one provided by another user, answers your question, please verify the answer. Thank you!Renesas Engineering Community Moderatorhttps://community.renesas.com/https://academy.renesas.com/https://en-support.renesas.com/knowledgeBase/
Hello JB,
Yes I just Copied the sample code & made some configuration changes accordingly.
actually I am using capacitive touch sensing keypad with RX-130 (Slave)whenever the key is pressed interrupt goes to the master pin and master send address (I2C communication )further happened.
Function for interrupt- F_INT_1msDelay(); //for master pin low to high.
Return value of the R_RIIC_SlaveTransfer() function-->Open RIIC success VersionId = version_id(V2.50) Get i2c status success,iic_status.LONG = 21269 slave transfer is timeout
I am Using Kinetic Mk64 as a Master. Please check attached ZIP file for configuration checking & check above waveform for your reference.
.riic_slavetransfer_demo_rskrx231.zip
It seems like there's a timeout detected. Please refer to chapter 6.3 of the application note to see how to handle this: https://www.renesas.com/us/en/document/apn/rx-family-i2c-bus-interfaceriic-module-using-firmware-integration-technology-rev260#page=70
Hello JB...
Yes I got timeout detection error .I referred chapter 6.3 application note how to handle timeout detection.
but this note is used for Master mode and I am using slave transfer mode.
Ref(A timeout may be detected due to a bus hang up. In master mode, if the clock signals from the master and slave devices go out of synchronization due to noise or other factors, the slave device may hold the SDA line low (bus hang up). Then the stop condition cannot be issued and a timeout will be detected.)
Second thing is my Data line & Clock line is not a low..Please check the attached waveform,
Looking forward with some adequate reply.
Are you using an RX130 target board? or you're using a custom board? Have you checked if there's no problem with the voltage levels? It seems like the MK64 operates at 3.3V while the RX130, if you're using a target board, operates at 5V or 3.3V. How about the master settings? Did you check if everything matches to the settings you've set with the slave device? I would recommend checking chapter 29.3.5 of the hardware user's manual to see the procedure and operations for slave transmission: https://www.renesas.com/us/en/document/mah/rx130-group-users-manual-hardware-rev300/chapter-29-3-5-slave-transmission.