Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    BMP388 MULTIPLE DEVICES USING SAME SPI BUS

    BMP388 MULTIPLE DEVICES USING SAME SPI BUS

    honoju
    Member

    Hello,

    I am using BMP388 sensors with the official Bosch API on a SPI bus of a STM32L476RG microcontroller. When I use only one BMP388 sensor, everything works fine.

    But I haven't succeded to communicate with multiple sensors on the same SPI bus, I can't even read the chip_ids. I am using the independant slave configuration as on the  image below ( the power supply being 3,3V and not 5V):

    honoju_0-1606314264165.png

     

    I have seen on this forum that with SPI protocol, one can use as many sensors as he needs with no added hardware. I have investigated the code run and I noticed that it is the sensor register reading that is problematic.

    Here is the location in the code where it bugs (it is in the bmp3_get_regs() function of the bmp3.c API file) :

     

    /* Read the data from the register */
    dev->intf_rslt = dev->read(reg_addr, temp_buff, temp_len, dev->intf_ptr);

     

     

    My user_spi_read function is as follows :

     

    int8_t user_spi_read(uint8_t addr_reg, uint8_t *data_reg, uint8_t len, void *intf_ptr)
    {
    	int8_t rslt = 0;
            
          /* resetting the good chip select pin */
    	if(intf_ptr == &dev_addr[0])
    		HAL_GPIO_WritePin(CS1_GPIO_Port, CS1_Pin, GPIO_PIN_RESET);
    	if(intf_ptr == &dev_addr[1])
    		HAL_GPIO_WritePin(CS2_GPIO_Port, CS2_Pin, GPIO_PIN_RESET);
    	if(intf_ptr == &dev_addr[2])
    		HAL_GPIO_WritePin(CS3_GPIO_Port, CS3_Pin, GPIO_PIN_RESET);
    	if(intf_ptr == &dev_addr[3])
    		HAL_GPIO_WritePin(CS4_GPIO_Port, CS4_Pin, GPIO_PIN_RESET);
    	if(intf_ptr == &dev_addr[4])
    		HAL_GPIO_WritePin(CS5_GPIO_Port, CS5_Pin, GPIO_PIN_RESET);
    	if(intf_ptr == &dev_addr[5])
    		HAL_GPIO_WritePin(CS6_GPIO_Port, CS6_Pin, GPIO_PIN_RESET);
    
             /* SPI transimission of the register to read*/
    	HAL_SPI_Transmit(&hspi1, &addr_reg, 1, HAL_MAX_DELAY);
    
             /* SPI reception of the data containedthe register read*/
    	HAL_SPI_Receive(&hspi1, data_reg, len, HAL_MAX_DELAY);
    
             /*setting the good chip select pin */
    	if(intf_ptr == &dev_addr[0])
    		HAL_GPIO_WritePin(CS1_GPIO_Port, CS1_Pin, GPIO_PIN_SET);
    	if(intf_ptr == &dev_addr[1])
    		HAL_GPIO_WritePin(CS2_GPIO_Port, CS2_Pin, GPIO_PIN_SET);
    	if(intf_ptr == &dev_addr[2])
    		HAL_GPIO_WritePin(CS3_GPIO_Port, CS3_Pin, GPIO_PIN_SET);
    	if(intf_ptr == &dev_addr[3])
    		HAL_GPIO_WritePin(CS4_GPIO_Port, CS4_Pin, GPIO_PIN_SET);
    	if(intf_ptr == &dev_addr[4])
    		HAL_GPIO_WritePin(CS5_GPIO_Port, CS5_Pin, GPIO_PIN_SET);
    	if(intf_ptr == &dev_addr[5])
    		HAL_GPIO_WritePin(CS6_GPIO_Port, CS6_Pin, GPIO_PIN_SET);
    
    	return rslt;
    }

     

     

    With this code, I read n+1 bytes (the first one being the dummy byte) from the sensor registers. For example, to read the chip_id, when I use one sensor I get two bytes the first one being the dummy byte (0xFF)  and the second one being the real chip_id byte (0x50). But when I use multiple sensors, I read twice the dummy byte value (0xFF).

    I have also seen on the net that for the SPI multiple independant devices configuration to work, pull-up resistors are required for chip select pins as tristate buffers for SDO pins. Does the BMP388 have these features or do we have to add them in order to use multiples BMP388 sensors on the same SPI bus?

    Thanks in advance for your help,

    Regards

    14 REPLIES 14

    BSTRobin
    Community Moderator
    Community Moderator

    Hello honoju,

    If you had not logic analyzer on your hand, you could try to check the following step:

    1.decrease SPI communication speed, 1MHz or lower.

    2.check SPI bus drive capability: test 2 slave devices, 3 slave devices, ... until 6 slave devices.

    Hello BSTRobin,

    Thanks for your tip. In fact, I succeeded communicating with 2 BMP388 lowering the frequency to 2,25 MHz.

    However, when I Tried with 3 BMP388 the communication was ruined. I lowered the frequency till 70 kHz with no success.

    I am using Adafruit BMP388 breakout board which has more components (voltage regulator, logical level shift, resistors, diods, ...) on it than the two 100 nF capacitors required by the BMP388 datasheet.

    So I pursued my investigations measuring the capacitance between the GND and the other pins to verify if the bug is not due to the capacitive load presented by the Adafruit BMP388 breakout board to the microcontroller.

    I am getting following values for the different pins :
    Capacitance values of pins.PNG

    I am suspecting the unrequired components (voltage regulator, ...) to present an excessive capacitance load to the microcontroller.

    I have tried to find breakout boards that don't all those unrequired components with no success. Do you have one to recommend?

    Regards,

    BSTRobin
    Community Moderator
    Community Moderator

    Hello Honoju,

    For Adafruit BMP388 breakout board  you used, could we know what is your power supply for 6 Adafruit BMP388 breakout boards?

    Suggest you supply 6 Adafruit BMP388 breakout boards with external regulated power supply, and check the current value change.

    Hello BSTRobin,

    I am supplying the BMP388 with the regulated 3.3 V power supply of the STM32L476RG microcontroller.

    BSTRobin
    Community Moderator
    Community Moderator

    Hello honoju,

    Do you mean you supply bmp388 and stm32l476rg microcontroller from samel voltage regulator? Such as LDO, etc. If LDO was used, I am not sure if the current is enough for both 6 Adafruit BMP388 breakout boards and STM32L476RG microcontroller.

    What I want to say is to use the regulator that supports large current to supply power first, and then test it after ensuring that the power supply is sufficient.

    External regulator.png

     

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist