Bosch Sensortec Community

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

    Can't read BMI085 ID

    Can't read BMI085 ID

    kilohercas
    Member

    Hello.
    FOr some reason i can't read any meaningfull registers, as well as chip ID, reading from 0 ADR gives 0xFF
    My read code is like this:

    of AC:
    CSA LOW
    SEND(ADR+1) // Does adress need to be shifter ?
    SEND(0)//DUMMY
    DATA=SEND(0) // Sending someting to read data
    CSA HIGH

    for GYRO:
    CSG_LOW
    SEND(ADR+1) // Does adress need to be shifter ?
    DATA=SEND(0) // Sending someting to read data
    CSG_HIGH

    But if i try to read ADR = 170, it does give some 0xE8 value.
    Any idea what i am doing wrong ? (CLK is below 1MHz for SPI)

    Datasheet could not give less information about SPI. no diagrams, no normal examples. even no normal register definition, just use our own API and don't ask questions.

     

    3 REPLIES 3

    kilohercas
    Member

    Very nice Bosh, very nice. So while reading forum i noticed, that read bit is not LSB, but MSB !!!!


    Now lets see what datasheet is saying:

    bmi085.PNG

    So bit zero is actually 0x80 or 10000000.

    Switched code for MSB bit for read operation, and what do you know, right answer in first time 🙂

    Pseudo code:
    CSA LOW
    SEND(ADR | 0x80)
    SEND(0)//DUMMY
    DATA=SEND(0)
    CSA HIGH

    STM32L5 code:
    uint8_t BMI085_Read_Register_ACC(uint8_t adr)
    {
    uint8_t data = 0;
    SPI1_CSG_GPIO_Port->HIGH = SPI1_CSA_Pin|SPI1_CSG_Pin;
    SPI1_CSG_GPIO_Port->LOW = SPI1_CSA_Pin;
    asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
    SPI1_Send_Recieve_byte(adr|0x80);

    SPI1_Send_Recieve_byte(0);

    data = SPI1_Send_Recieve_byte(0);

    asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
    asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
    asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
    SPI1_CSG_GPIO_Port->HIGH = SPI1_CSA_Pin|SPI1_CSG_Pin;
    return data;
    }

    Please fix datasheet and add some complete SPI timing diagram. Just as i suspected, extremely poorly written datasheet !

     

    FAE_CA1
    Community Moderator
    Community Moderator

    Hi,

    Thanks for your inquiry.

    BMI085 supports SPI mode 0 and 3. The gyro part is staight forward. When you send 0x80 to read gyro chip ID at adress of 0x00, then you will immediately get the correct value of 0x0F back. For accel part after you send 0x80 to read accel chip ID at address of 0x00, you will get a dummy byte back. After you send another any byte such as 0x00 or 0xFF, you will get the correct value of 0x1F back.

    Please refer to the SPI interface part for BMA456 on page 81 at https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bma456-ds000.pdf for more information.

    Thanks.

    Yes, this is correct. But datasheet says different things. When i figure out this part, it start working, and all my code works. I was bale to get ac and gyro data with no API , so far so good.

    Please inform bosh who is making datasheet to include spi diagram and correct erros how to read/write data since it has wrong definition for write bit.

    in your linked pdf it's correct 🙂

    Thank you !

    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