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,

    Please check sensor power supply (current/voltage), record the waveform by oscilloscope or logic analyzer.

    And let us know your check result.

    BSTRobin
    Community Moderator
    Community Moderator

    Hello Honoju,

    Have you tried to check it?

    Hello BSTRobin,

    Sorry for the long time with no response, I have been away from work.

    We recently acquired a regulated voltage supply, I'm going to try it and get back to you when it is done.

    Regards,

    Hello BSTRobin,

    We are now considering designing our own PCBs to overcome the failure.

    Thanks for your help,

     

    BSTRobin
    Community Moderator
    Community Moderator

    Hello Honoju,

    Okay.

    In the new hardware design, the SPI line should be as short as possible, and the power supply should be enough.

    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