0
\$\begingroup\$

Hello I am trying to communicate with TI BQ28Z610 by using Nucleo-F746ZG. All I do is trying to read data from TI chip. I am sending 0x08 to slave address 0x55.I2C frequency is 80kHz and pull ups are 10 K. Here is the related part of the trial code:

while (1)
    {
        /* USER CODE END WHILE */

        /* USER CODE BEGIN 3 */
        //READ VOLTAGE FOR TESTING

#define I2C_Slave_Address (0x55) // Receive 0x55+1    0x55
        uint8_t I2C_Data[16];
        uint8_t I2C_DataToSend;
        char statusString[255];
        int statusStringLength;
        I2C_DataToSend=0x08;

        if (HAL_OK != HAL_I2C_Master_Transmit(&hi2c1,(uint8_t)I2C_Slave_Address,&I2C_DataToSend,1,1000)){
            statusStringLength = sprintf(statusString,"Transmit failed");
            CDC_Transmit_FS(statusString,statusStringLength);
            HAL_GPIO_WritePin(LD1_GPIO_Port,LD1_Pin,1);
        }




        if (HAL_OK != HAL_I2C_Master_Receive(&hi2c1,(uint8_t)I2C_Slave_Address + 1 , I2C_Data,1,1000)){

            statusStringLength = sprintf(statusString,"Receive failed");
            CDC_Transmit_FS(statusString,statusStringLength);
            HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin,1);

        }
        statusStringLength = sprintf(statusString,"Voltage: %d", (int) I2C_Data[0]);
        CDC_Transmit_FS(statusString,statusStringLength);
        HAL_Delay(100);
    }

Here is the oscilloscope image: Oscilloscope View

Here is the logic analyzor view:

Logic Analyzer View

So what might be the reason behind it? For me everything looks fine. Thank you beforehand. Edit: Here is the logic analyzer capture for 0xAA slave address: Logic Analyzer capture for 0xAA

\$\endgroup\$
1
  • \$\begingroup\$ Are you sure the chip is working? It could be damaged somehow. I would try with something like BusPirate or co. to identify the problem. If you are at an university or at a firm, somebody has to have one. This try eliminates all typos or misunderstanding in the code. Check the supply voltage at the sensor, also double check the layout and the pinout! If you have a microscope look for opens or shorts. Also check the datasheet about the frequency range of the sensor, sometimes they are picky. \$\endgroup\$ Apr 10, 2020 at 10:59

2 Answers 2

2
\$\begingroup\$

The slave address is wrong. It is 0xAA for write and 0xAB for read. Your define has 0x16. The chip won't answer at that address, so you see the NAK after address 0x16 on the scope shot.

\$\endgroup\$
7
  • \$\begingroup\$ You are right, please check the edited question. \$\endgroup\$ Apr 10, 2020 at 9:06
  • 2
    \$\begingroup\$ I don't understand what are you trying to say. You still use wrong address! I said to use 0xAA and 0xAB but you changed to 0x55 and 0x56 which are still wrong. The logic analyser uses 7-bit address notation, where the address is 0x55 with a separate read/write bit, while the STM32 HAL uses 8-bit address notation where 0xAA is used for writing and 0xAB is used for reading. It means the exact same thing on the bus. You might be able to change how your logic analyzer decodes the address if this is new to you. \$\endgroup\$
    – Justme
    Apr 10, 2020 at 9:38
  • \$\begingroup\$ So I need to send 0xAA as slave address not 0x55. Am I right? \$\endgroup\$ Apr 10, 2020 at 9:41
  • 1
    \$\begingroup\$ That is what I have said many times. 0xAA. \$\endgroup\$
    – Justme
    Apr 10, 2020 at 9:42
  • \$\begingroup\$ So the slave device has a problem because although I am sendin 0xAA there is still a NACK \$\endgroup\$ Apr 10, 2020 at 9:44
1
\$\begingroup\$

Per the logic analyzer view, you are receiving a NACK to the address, indicating that there is no slave at the address you are sending.

According to the BQ28Z610 Technical Reference, page 57 (here), the device has a slave address of 0x55 (7-bit) so unless you are using some sort of address translation chip, slave address 0x16 is wrong.

Try correcting the address.

\$\endgroup\$
2
  • \$\begingroup\$ Yes I also tried with 0x55. Still a NACK. When I send 0x55 there is 2A in the logic analyzer. So I think I cannot see what I am trying to send in the logic analyzer. And when I try to send 0xAA or 0xAB there is 0x55 in the logic analyzer. \$\endgroup\$ Apr 10, 2020 at 9:02
  • \$\begingroup\$ Please check the edited question. \$\endgroup\$ Apr 10, 2020 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.