- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
I am trying to connect MLX90614 to CYBT-343026 using I2C communication. I have connected SDA and SCL to the highlighted pin.
I have chosen WICED_I2C_SDA_I2S_DOUT_PCM_OUT_SCL_I2S_DIN_PCM_IN (also tried using WICED_I2C_SDA_P35_SCL_P37 but no result.) because in datasheet pin description has below detail.
I have written the below code. Also, I have attached the code file for your reference.
APPLICATION_START()
{
wiced_transport_init( &transport_cfg );
wiced_set_debug_uart( WICED_ROUTE_DEBUG_TO_HCI_UART );
wiced_hal_puart_set_baudrate(115200);
WICED_BT_TRACE("**** App Start **** \n\r");
uint8 wbuf[2]={0};
uint8 rbuf[3]={0};
wiced_hal_i2c_init(WICED_I2C_SDA_I2S_DOUT_PCM_OUT_SCL_I2S_DIN_PCM_IN );
wiced_hal_i2c_set_speed(I2CM_SPEED_100KHZ);
wbuf[0]=0x07;
int wstatus = wiced_hal_i2c_write(wbuf,1,0x5A);
wiced_hal_i2c_read(rbuf,3,0x5A);
WICED_BT_TRACE("\nvalues %X %d \n\r",rbuf[0],wstatus);
WICED_BT_TRACE("**** App End **** \n\r");
}
But I am getting the everytime same output
**** App Start ****
values FF 1
**** App End ****
------------------------------------------------------------------------------------------------------
In wiced_hal_i2c.h library I can only see wiced_hal_i2c_read() function has parameters of readbuf,buflength and slave address, but I had done the same in PSOC creator there was I2C_1_I2C_MODE_NO_STOP parameter to wait for a response. Similarly in this modustoolbox how can implement the same?
PSOC Creator I2C function:
uint8 readRegister(uint8 address,uint8 *Wbuff,uint8 *Rbuff){
// SW_Tx_UART_1_PutHexInt(address);
I2C_1_I2CMasterWriteBuf(address, (uint8 *)Wbuff, 1, I2C_1_I2C_MODE_NO_STOP);
while((I2C_1_I2CMasterStatus() & I2C_1_I2C_MSTAT_WR_CMPLT)==0){}
I2C_1_I2CMasterReadBuf(address, (uint8 *)Rbuff, sizeof(Rbuff), I2C_1_I2C_MODE_REPEAT_START);
while((I2C_1_I2CMasterStatus() & I2C_1_I2C_MSTAT_RD_CMPLT)==0){}
// SW_Tx_UART_1_PutString("Received : ");
// SW_Tx_UART_1_PutHexInt(Rbuff[0]);
/// SW_Tx_UART_1_PutString("\n");
return Rbuff[0];
}
Please correct me if I am wrong. above code is sufficient to read the i2c device's register value? or I am missing anything?
Thanks in advance.
Regards
Neeraj
Solved! Go to Solution.
- Tags:
- cybt-343026
- i2c
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello AnjanaM_61,
The problem has been solved. The problem was in the I2C Slave address you had given a reply in #3 and suggested to shift the slave address right by 1.
#define I2C_ADDRESS (0xYY >> 1) /*I2C sensor slave address*/
After checking the CYW920706WCDEVAL Hardware User Guide I saw the slave address shifted left by 1 and not right.
it should be #define I2C_ADDRESS (0xYY << 1) /*I2C sensor slave address*/
Also, there was 1 more change as my I2C sensor gives a response on demand (I2C write request) instead of using wiced_hal_i2c_write() and then wiced_hal_i2c_read() is used wiced_hal_i2c_combo_read() and it works for me.
Thank you so much for your help Anjana
Thanks and regards,
Neeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi NeDh_4602711 ,
Can You try the example code provided here: Re: Question problem i2c CYW20706 & CYBT-343026-eval
Also, I would suggest you to use PUART for debug logs. You may have to use the PUART pins correctly and call wiced_hal_puart_select_uart_pads
Regards,
Anjana
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello AnjanaM_61
As per your suggestion, I have used PUART for debug logs and I did the same code as per your example. But still, it is not working I am getting below output.
**** App Start ****
incoming data: 255 255 255 0 0
**** App Ends ****
Also, I have checked the status value of wiced_hal_i2c_read() as well as wiced_hal_i2c_write() both are 0 which means it is showing as a success. but the value which I am receiving is not as per my expectation. Also, I have checked the sensor it is working with other controllers. So sensor is also not defected.
I have also attached the code for your reference.
Could you please check the code. One thing I don't understand here, there is no concept of mode? like I have given an example in my first post in PSOC creator there was I2C_1_I2C_MODE_NO_STOP parameter to wait for a response. like there is no such concept?
Thanks and regards,
Neeraj Dhekale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi NeDh_4602711 ,
Do you have a logic analyzer ? If then , can you probe the I2C & SDK lines and see if you can see the same data or not ?
Hope you have connected a common ground between the sensor and 343026 as well.
Also , could you please try by passing the slave address shifted by 1?
Say #define I2C_ADDRESS (0xYY >> 1) /*I2C sensor slave address*/
Regards,
Anjana
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Anjana,
Need to check on a logic analyzer. But I am getting the desired output on
CYPRESS’s CYBLE-0220001-00 module. Yes, I have connected common ground
between both.
Also tried using address shift by 1 as per your suggestion, but it is not
working.
I am still trying with all possible codes and connections.
Thanks and regards
Neeraj
On Wed, 15 Jul 2020 at 2:43 PM, AnjanaM_61 <community-manager@cypress.com>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have tested with all possible codes and connections. I thought there may be a problem with the CYBT-343026 module & I have tried even by replacing the controller. But facing the same issue. It is pretty straight forward. I wonder do really this module has I2C support? or there is an issue with library wiced_hal_i2c.h?
MLX90614 (I2C) device is very simple you have to write 0x07 / 0x06 in 0x5A address and you will get 2 bytes temperature data from 0x5A address. That's it.
Everytime when I call wiced_hal_i2c_write() and try to write data it returns value '1'. i.e.: Failure. I also tried to google it but there is no good example to get a hint of what's wrong in my code. Everywhere it is written for I2C in the CYBT modules- unfortunately example code is not available.
If anyone knows what I am doing wrong. Please help. The code file is attached for your reference.
Thanks and regards,
Neeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have checked on DSO by comparing signals from the CYBLE-022001-00 module with CYBT-343026-00 module.
First I have checked SDA and SCL signals when MLX90614 sensor connected to the CYBLE-022001-00 module.
SCL :
SDA:
Then I connect my MLX90614 sensor to CYBT343026 module and I got below signals on DSO
SCL:
SDA:
Please let me know what can be the problem.
Thanks in advance.
Regards,
Neeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello AnjanaM_61,
The problem has been solved. The problem was in the I2C Slave address you had given a reply in #3 and suggested to shift the slave address right by 1.
#define I2C_ADDRESS (0xYY >> 1) /*I2C sensor slave address*/
After checking the CYW920706WCDEVAL Hardware User Guide I saw the slave address shifted left by 1 and not right.
it should be #define I2C_ADDRESS (0xYY << 1) /*I2C sensor slave address*/
Also, there was 1 more change as my I2C sensor gives a response on demand (I2C write request) instead of using wiced_hal_i2c_write() and then wiced_hal_i2c_read() is used wiced_hal_i2c_combo_read() and it works for me.
Thank you so much for your help Anjana
Thanks and regards,
Neeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi NeDh_4602711 ,
Oh I am sorry I made the mistake in address shift.
Good to know that it worked for you. Thanks so much for the update.
Regards,
Anjana