06-03-2019 01:57 AM
I am trying to implement the BMP388 (for what its worth, I've done a bunch with the BMP280, so I sort of know my way around).
The problem is, when I read the block from address 0x04 (the start of the data registers), the first byte in the pressure and the first byte in the temperature are always zero. The whole dummybyte in the SPI got me for a while, but that is not the issue here (i've tried starting at address 0x03, and read through to 0x09 to verify)
I've also read the 3 bytes in sensortime (addr 0x0C) and am seeing the bytes incriment as expected. I'm using the same code for reading the pressure bytes, so I'm at a loss for why the first byte is good in the sensortime, but always zero for the pressure or temperature blocks.
For clarification, here is what I am seeing:
Addr[0x04] = 0x00 <=== shouldn't this be non-zero, or change over subsequent reads?
Addr[0x05] = 0xF2 this fluctuates, which is expected
Addr[0x06] = 0x6C this is mostly static, but since it is the high bits, I would expect this behavior as well
Addr[0x07] = 0x00 <=== shouldn't this be non-zero
Addr[0x08] = 0xBC
Addr[0x09] = 0x81
I've tried reading these registers a number of different ways:
Single-byte reads for each of the above registers
Block read for 0x04-0x06 (and another block read from 0x07-0x09
Block read starting at 0x03
Block read starting at 0x04
From everything I can see, it appears that the first byte for temperature and pressure is just not being set. Any idea what is going on here?
06-05-2019 03:06 AM
By definition, the SPI communication is always bi-directional, but in the Bosch SPI protocol, there is always only one valid byte.
Could it simply be that your MCU code needs to throw away 2 bytes ? (one read while transferring the register address, then a second one for the dummy byte)
In any case, are you able to provide a screenshot of a logic analyzer to make sure that your are decoding the bus transactions properly?
06-05-2019 05:42 AM
It appears that this is a factor of the ODR and OSR. 3.4.1 in the data sheet mentions this, and is sort of what I thought would be the culprit. Oversampling controls the resolution and the low order bits are set to zero unless OSR is 32x. Having all 8 bits zeroed threw me off. Incidentally, the example code on github turns off oversampling. It would be helpful to add some examples of higher resolution settings.
I still dont have a good feel for the optimal setting (i.e. what setting yeilds the fastest sample rate as well as highest resolution?)
The API kicks out invalid combinations, but I'm still a bit lost for the proper settings. Do you have some cookie-cutter setting combinations?
06-07-2019 08:49 PM - edited 06-07-2019 08:54 PM
I can confirm successful operation of BMP3-Sensor-API v1.1.0, 05 Apr 2018 using SPI. The following SPI transactions were obtained by calling bmp3_get_sensor_data(BMP3_PRESS | BMP3_TEMP, ...).
TX: 84 00 72 6B 75 20 EE 92 RX: 00 00 66 6B 75 58 EE 92 TX: 84 00 66 6B 75 58 EE 92 RX: 00 00 6C 6B 75 C2 ED 92 TX: 84 00 6C 6B 75 C2 ED 92 RX: 00 00 61 6B 75 91 ED 92 TX: 84 00 61 6B 75 91 ED 92 RX: 00 00 39 6B 75 AD ED 92
The first byte is zero because this is the byte received during the transmission of the control byte (0x84). The second byte is zero because this is the "dummy byte" as described on page 42 of datasheet v1.1.
@Spanky wrote:Do you have some cookie-cutter setting combinations?
Page 16 of datasheet v1.1 describes the recommended settings for six use cases. I use the following initialisation code to implement the "drone" use case. This achieves an ODR of 50 Hz. Lower ODRs can result in a large phase lag that I judge not to be worth the reduction in noise.
// Configure device structure bmp3.intf = BMP3_SPI_INTF; bmp3.read = Bmp3Read; bmp3.write = Bmp3Write; bmp3.delay_ms = Bmp3Delay; // Initialise device bmp3_init(&bmp3); // Perform soft reset bmp3_soft_reset(&bmp3); // Configure settings for drone use case as per datasheet bmp3.settings.press_en = BMP3_ENABLE; bmp3.settings.temp_en = BMP3_ENABLE; bmp3.settings.odr_filter.press_os = BMP3_OVERSAMPLING_8X; bmp3.settings.odr_filter.temp_os = BMP3_NO_OVERSAMPLING; bmp3.settings.odr_filter.iir_filter = BMP3_IIR_FILTER_COEFF_3; bmp3.settings.odr_filter.odr = BMP3_ODR_50_HZ; bmp3_set_sensor_settings(BMP3_PRESS_EN_SEL | BMP3_TEMP_EN_SEL | BMP3_PRESS_OS_SEL | BMP3_TEMP_OS_SEL | BMP3_IIR_FILTER_SEL | BMP3_ODR_SEL, &bmp3); // Set the power mode to normal mode bmp3.settings.op_mode = BMP3_NORMAL_MODE; bmp3_set_op_mode(&bmp3);