Hello,
I have device IO expander TCA9535PWR with address 0x21. When MCU try to set output to the device it's works.
But when try to read Input, iic_info_m.dev_sts status is always RIIC_COMMUNICATION. So it's stuck in while loop.
Here my code :
#define ADDR_IOCTRL_FRONT 0x21 #define ADDR_IOCTRL_REAR 0x20 BYTE addr_IOCtrl[2] = { ADDR_IOCTRL_REAR, ADDR_IOCTRL_FRONT }; BYTE readInput_Front() { volatile riic_return_t ret; /* Return value */ BYTE receive_data[8] = { 0xFF }; iic_info_m.dev_sts = RIIC_NO_INIT; //Device state flag iic_info_m.p_slv_adr = addr_IOCtrl + 1; /* Pointer to the slave address Front IO Expander */ iic_info_m.p_data1st = RegAddr; /* Pointer to Register Input Port 0 */ iic_info_m.cnt1st = 1; iic_info_m.p_data2nd = receive_data; iic_info_m.cnt2nd = 1; iic_info_m.callbackfunc = &CallbackMaster; ret = R_RIIC_Open(&iic_info_m); /* RIIC receive start */ ret = R_RIIC_MasterReceive(&iic_info_m); if (RIIC_SUCCESS == ret) { while( != iic_info_m.dev_sts); //Stuck here } else { /* error */ } ret = R_RIIC_Close(&iic_info_m); /* RIIC receive complete */ return receive_data[1]; }
Could you help me ??
Thank you
Hello iamno3,
In this line
iic_info_m.p_slv_adr = addr_IOCtrl + 1;
why do you add 1 to the address? Is it the real address of the device or are you trying to add the "Read" bit to it? In the last case…
Hello Sergey,
Thank you for reply.
addr_IOCtrl is pointer to array so addr_IOCtrl + 1 is ADDR_IOCTRL_FRONT address value.
addr_IOCtrl
I think problem is with IO expander it self. Sample code already work. One IC…