Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    I can't get BMX160 CHIPID using STM32 SPI

    zx556605
    New Poster

    Re: I can't get BMX160 CHIPID using STM32 SPI

    Hello~~Fish
    At present, there is no oscilloscope on hand, and the SPI wave signal is attached later.
    I currently have two questions. Thank you~~
    1. Use BMX160 Shuttle Board to communicate through SPI, CS PIN needs set zero or one at the beginning ???
    2. According to your last reply, I executed rslt = null_ptr_check(dev) in the int8_t bmi160_init (struct bmi160_dev * dev) function, and the result is zero, so it means that my SPI pre-operation should be completed?? It is just whether the MCU uses SPI to connect with BMX160 Success depends on the wave pattern?

    fish
    Community Moderator

    Re: I can't get BMX160 CHIPID using STM32 SPI

    1. Use BMX160 Shuttle Board to communicate through SPI, CS PIN needs set zero or one at the beginning ???

    In fact,  if use SPI interface, CS Pin need a raising edge after BMX160 power, from 0 to 1. You need switch CS Pin from 0 to 1 before SPI communication.
    2. According to your last reply, I executed rslt = null_ptr_check(dev) in the int8_t bmi160_init (struct bmi160_dev * dev) function, and the result is zero, so it means that my SPI pre-operation should be completed?? It is just whether the MCU uses SPI to connect with BMX160 Success depends on the wave pattern?

    In function bmi160_init(), dummy read will enable SPI Interface, as bellow

    /* Dummy read of 0x7F register to enable SPI Interface
    * if SPI is used */
    if ((rslt == BMI160_OK) && (dev->interface == BMI160_SPI_INTF))
    {
    rslt = bmi160_get_regs(BMI160_SPI_COMM_TEST_ADDR, &data, 1, dev);
    }

     
     
     
    zx556605
    New Poster

    Re: I can't get BMX160 CHIPID using STM32 SPI

    The attachment is the wave signal diagram of my SPI
    I feel there is SPI communication between MCU and BMX160
    Yellow: BMX160 receives MCU Clock signal
    Blue: BMX160 receives MCU signal
    Purple: BMX160 signal sent to MCU
    -------------------------------------------------- -------------
    Currently!!! My CODE steps are as follows
    1. CS =HIGH after power on
    2. struct bmi160_dev bmi;
    3.rslt = bmi160_init(&bmi);
    -------------------------------------------------- -------------
    But in run rslt = bmi160_init(&bmi);
    Get the result rslt=-3 (BMI160_E_DEV_NOT_FOUND)
    Will it be me bmi.read = (bmi160_com_fptr_t)user_spi_read
    user_spi_read function writing error!!

     

    103840888_3252638701447025_4412533997326217515_n.jpg

    fish
    Community Moderator

    Re: I can't get BMX160 CHIPID using STM32 SPI

    1 CSB Pin voltage keep high, the interface is I2C. CSB voltage switch from low to high, the interface switch to SPI.

    2 Check SPI configuration is right. The attachment photo isn't SPI protocol. You could refer to chapter 3.2 SPI Interface for more details.

    3 From my suggestion, you could run SPI example on your platform, make sure SPI communication is OK. Then, integrate sensor driver.

       I think the platform provide some example to verify SPI communication.

    Hopefully, you could quickly fix this issue.

    zx556605
    New Poster

    Re: I can't get BMX160 CHIPID using STM32 SPI

    -----------------------------------------------------------------------------------
    struct bmi160_dev bmi;
    bmi.id = 0;
    bmi.interface = BMI160_SPI_INTF;
    bmi.read = (bmi160_com_fptr_t)user_spi_read;
    bmi.write = (bmi160_com_fptr_t)user_spi_write;
    bmi.delay_ms = (bmi160_delay_fptr_t) Delayus;
    -----------------------------------------------------------------------------------
    I would like to ask!!!
    bmi.read = (bmi160_com_fptr_t)user_spi_read;
    bmi.write = (bmi160_com_fptr_t)user_spi_write;
    The workflow of these two functions and how to write

    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