12-24-2022 03:42 AM
Hi, I'm using BME688 in a custom board with nRF52840 microcontroller running Zephyr RTOS. I modified the common.c file from bme68x API and checked the I2C transactions with a logic analizer to verify that read/write procedure is in the right format (page 46 in the datasheet).
Here are the i2c and delay functions that I edited from the original common.c file available in GitHub. i2c_dev is a structure pointer to the i2c peripheral used by Zephyr.
BME68X_INTF_RET_TYPE bme68x_i2c_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *intf_ptr)
{
return i2c_burst_read(i2c_dev, dev_addr, reg_addr, reg_data, len);
}
BME68X_INTF_RET_TYPE bme68x_i2c_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len, void *intf_ptr)
{
uint8_t tx_buf[len + 1];
tx_buf[0] = reg_addr;
memcpy(tx_buf + 1, reg_data, len);
return i2c_write(i2c_dev, tx_buf , len + 1, dev_addr);
}
void bme68x_delay_us(uint32_t period, void *intf_ptr)
{
k_usleep(period);
}
Here is a read timming example to get the chip id. Burst read also works fine.
Here is a burst write example. As in datasheet's page 46, there is no auto-increment, as you can see the register address increments by 1: 0x71, 0x72, ..., 0x75.
The problem:
When I run the self-check, this message appears:
API name [bme68x_selftest_check] Warning [2] : No new data found
And when I try the forced mode example, I always get this output :
API name [bme68x_init] OK [0]
API name [bme68x_set_conf] OK [0]
API name [bme68x_set_heatr_conf]OK [0]
Sample, TimeStamp(ms), Temperature(deg C), Pressure(Pa), Humidity(%), Gas resistance(ohm), Status
API name [bme68x_set_op_mode] OK [0]
API name [bme68x_get_data] Warning [2] : No new data found
API name [bme68x_set_op_mode] OK [0]
API name [bme68x_get_data] OK [0]
1, 3852, 0, 1107730122, 1200501, 1120403456, 0x80
API name [bme68x_set_op_mode] OK [0]
API name [bme68x_get_data] OK [0]
2, 4010, 0, 1107730122, 1200501, 1120403456, 0x80
API name [bme68x_set_op_mode] OK [0]
API name [bme68x_get_data] OK [0]
3, 4168, 0, 1107730122, 1200501, 1120403456, 0x80
API name [bme68x_set_op_mode] OK [0]
API name [bme68x_get_data] OK [0]
4, 4326, 0, 1107730122, 1200501, 1120403456, 0x80
API name [bme68x_set_op_mode] OK [0]
API name [bme68x_get_data] OK [0]
5, 4485, 0, 1107730122, 1200501, 1120403456, 0x80
(...)
This is how it looks like at the logic analizer:
I'm not using the FPU and I just changed the line time_ms = coines_get_millis(); to:
12-26-2022 08:43 AM