I2C communication

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
*******************************************************************************/

Parents Reply Children
No Data