11-03-2021 09:18 AM
Hi,
I'm trying to communicate nrF52832 and BHA260AB shuttle board but I cannot get the chip ID. I checked with the logic analyzer and saw the ACK is returned.
this is I2C read function:
int8_t twi_read(uint8_t sl_addr, uint8_t reg_addr, uint8_t* output, uint8_t len)
{
ret_code_t err_code;
err_code = nrf_drv_twi_tx(&m_twi, sl_addr, ®_addr, 1, false);
APP_ERROR_CHECK(err_code);
nrf_delay_us(300); //not work if no delay
NRF_LOG_FLUSH();
err_code = nrf_drv_twi_rx(&m_twi, sl_addr, output, len);
APP_ERROR_CHECK(err_code);
nrf_delay_us(500); //delay to wait for the response
if(rx_done)
return 0;
else
return -1;
}
Please tell me what is the problem here? thanks.
Solved! Go to Solution.
11-04-2021 09:11 AM
Hello Minh,
Sorry, the address should be shifted one bit to the left like this.
slave_address << 1
11-05-2021 03:09 AM
yes. At the first testing, I showed you above, I used address 0x28 << 1 = 0x50 then I received ACK from the BHA260 chipset. But I don't know why the chip ID that I read is 0x00. Currently, I trying to upload firmware to the BHA260 chipset to see how.
11-05-2021 08:27 AM
Hello Minh,
I could see clearly for your HW connection.
Make sure your hardware is properly connected. When using I2C, the HCSB pin must be pulled high.
Could you check your HW connection and try it again?
11-05-2021 09:08 AM
Hi BSTRobin,
I checked
HCSB pin connected to VDDIO_1V8
HSCX and HSDX connected to pull-up registers
HSDO connected to VDDIO_1V8 (select the address 0x28)
I tried with a command and I received ACK with the address 0x50
thanks
11-05-2021 09:54 AM - edited 11-05-2021 10:16 AM
Hello Minh,
For your reply "HSDO connected to VDDIO_1V8 (select the address 0x28)", BHI260AB I2C address should be 0x29.
You waveform was not correct. The following code for your reference.
uint8_t chip_id;
BHI260_SensorAPI_I2Cx_Read(0x29, 0x2B, &chip_id, 1);
PDEBUG("BHI260AB chipd ID=%02X\r\n", chip_id);
int8_t BHI260_SensorAPI_I2Cx_Read(uint8_t slave_address7, uint8_t subaddress, uint8_t *pBuffer, uint16_t ReadNumbr)
{
uint16_t DevAddress = slave_address7 << 1;
HAL_I2C_Master_Transmit(&I2C_HANDLE, DevAddress, &subaddress, 1, BUS_TIMEOUT);
HAL_I2C_Master_Receive(&I2C_HANDLE, DevAddress, pBuffer, ReadNumbr, BUS_TIMEOUT);
return 0;
}
Because I only have the hardware of BHI260AB on my hand, my previous test is based on BHI260AB .
For BHA260AB , if you correctly read the chip ID, its return value will be 0x74 or 0xf4