Can I get the sample code for for RX130 I2C Communication?
I have to send data another controller through I2C.
I am Using RX-130 as a slave.
Hi AJ,
Have you checked these application notes and sample codes?
https://www.renesas.com/us/en/document/apn/rx-family-simple-i2c-module-using-firmware-integration-technology-rev250
https://www.renesas…
https://www.renesas.com/us/en/document/scd/rx-family-simple-i2c-module-using-firmware-integration-technology-rev250-sample-code
https://www.renesas.com/us/en/document/apn/rx-family-i2c-bus-interfaceriic-module-using-firmware-integration-technology-rev260
https://www.renesas.com/us/en/document/scd/rx-family-i2c-bus-interface-riic-module-using-firmware-integration-technology-rev260-sample-code
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 Mr JB sir...
I get your codes, but this code is not working for RX 130 controller.
I made all changes as per manual but I am not able to perform I2C application.
Can I get RX 130 sample code.
Apologies for the delayed response. How are things going? Unfortunately, I don't have any sample code anymore as I don't use this device. That sample code should work as it includes the RX130 as a target device. But you should also refer to your device hardware user's manual to see other notes in using the I2C peripheral.
Hello JB....
I am trying to solve I2C communication issue from last few days but I am not able to solve this issue yet .I communicate with Renesas forum but I don't get any correct solution.
1.Please check my attached Rx130 sample code with EEPROM.
2.Please check my attached screenshot of configuration.
3.In Interrupt configuration files I am not able to see the Used interrupt vector.
I hope above information will help me for solve this issue & I get the correct solution.
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 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 <string.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 ******************************************************************************/ static uint32_t send_count = 0; static void master_call_back(void); static riic_info_t iic_info_m; /******************************************************************************* * Function Name: main * Description : api demo of riic communication (master send) * Arguments : * Return Value : *******************************************************************************/ void main(void) { uint32_t version_id = 0; volatile riic_return_t ret; uint8_t addr_eeprom[1] = {0x50}; uint8_t access_addr1[1] = {0x00}; uint8_t mst_send_data[8] = {'R','e','n','e','s','a','s','\0'}; iic_info_m.dev_sts = RIIC_NO_INIT; /*init the riic communication structure*/ iic_info_m.ch_no = 0; iic_info_m.callbackfunc = &master_call_back; iic_info_m.cnt2nd = 7; iic_info_m.cnt1st = 1; iic_info_m.p_data2nd = mst_send_data; iic_info_m.p_data1st = access_addr1; iic_info_m.p_slv_adr = addr_eeprom; printf("iic_info_m.p_data2nd = %s\n",mst_send_data); ret = R_RIIC_Open(&iic_info_m); /* Open RIIC */ if (RIIC_SUCCESS != ret) { printf("Open I2C failed \n"); return; } else { printf("Open I2C success!!\n"); } version_id = R_RIIC_GetVersion(); /* Get RIIC Version ID */ printf("VersionId = version_id(V%d.%d)\n",((version_id >> 16) & 0x00FF), (version_id & 0x00FF)); ret = R_RIIC_MasterSend(&iic_info_m); /* RIIC Master Send Start */ if (RIIC_SUCCESS != ret) /* To determine whether the Master send return value is success */ { printf("Master Send failed ,return Value is %d\n",ret); R_RIIC_Close(&iic_info_m); return; } else { while (1) { if (RIIC_FINISH != iic_info_m.dev_sts) /* To determine whether the transmission is over */ { if(RIIC_NACK != iic_info_m.dev_sts) /* To determine whether the status is NACK */ { if(RIIC_TMO != iic_info_m.dev_sts)/* To determine whether the status is TimeOut */ { continue; /* RIIC Transfer is not Time out,continue wait */ } else { printf("RIIC Transfer is Time out\n"); /* RIIC Transfer is Time out */ break; } } else { if (send_count >= 200) /* To determine whether the send count is more than 200s */ { printf("the number of send times is %d\n",send_count); break; } else { R_BSP_SoftwareDelay(100, BSP_DELAY_MICROSECS); send_count++; /* send count plus 1,and send data once more */ iic_info_m.dev_sts = RIIC_NO_INIT; /*init the riic communication structure*/ iic_info_m.cnt2nd = 7; iic_info_m.cnt1st = 1; iic_info_m.p_data2nd = mst_send_data; iic_info_m.p_data1st = access_addr1; ret = R_RIIC_MasterSend(&iic_info_m); if (RIIC_SUCCESS != ret) { printf("Master Send failed ,return Value is %d\n",ret); break; } else { printf("the number of send times is %d\n",send_count); continue; } } } } else { printf("iic_info_m.dev_sts = %d\n",iic_info_m.dev_sts); printf("Master send Data has finished\n"); break; } } } R_RIIC_Close(&iic_info_m);/* RIIC transfer is over ,close the RIIC bus */ printf("RIIC transfer is over,close the RIIC Channel\n"); return; } /******************************************************************************* End of function main *******************************************************************************/ /******************************************************************************* * Function Name: master_call_back * Description : callback function of RIIC API * Arguments : * Return Value : *******************************************************************************/ static void master_call_back(void) { volatile riic_return_t ret; riic_mcu_status_t iic_status; /* Get I2C Status */ ret = R_RIIC_GetStatus(&iic_info_m, &iic_status); if (RIIC_SUCCESS != ret) { printf("Get I2C Status failed\n"); } else { printf("iic_status.LONG = %x\n",iic_status.LONG); } return; } /******************************************************************************* End of function master_call_back *******************************************************************************/
Unfortunately, I don't have an RX130 on hand so I can't try this one. Have you tried debugging it? What errors are you receiving? Did you successfully open the I2C port when you call the R_RIIC_Open() function? What return value did it return?