Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BNO055 bus read and bus write function not working

    BNO055 bus read and bus write function not working

    rbtics
    Member

    Hi, 

    I'm using the template from the BOSCH github to write my I2C bus read and write functions however I can't seem to get it working. I'm using the PSOC generated I2C API's to do the process of bit reading/writing but it seems my I2CMasterSendStart function doesn't return anything. Any help would be great! Thank you

    s8 BNO055_I2C_bus_write(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
    {
    s32 BNO055_iERROR = 0; // this is the "status" we usually use in our R/W functions
    u8 idx;

    uint32 timeoutMs = 0; //ms

    BNO055_iERROR = imu_bno055_I2CMasterSendStart(dev_addr, imu_bno055_I2C_WRITE_XFER_MODE,timeoutMs);
    //^^error occuring here

    // Check for BNO055_iERROR before proceeding
    BNO055_iERROR = imu_bno055_I2CMasterWriteByte(reg_addr,timeoutMs);

    for (idx = 0; (idx < cnt) && (BNO055_iERROR == 0); idx++)
    {
    BNO055_iERROR = imu_bno055_I2CMasterWriteByte(reg_data[idx],timeoutMs);
    //I2C_UART_UartPutString(" bit writing in progress");
    }
    //I2C_UART_UartPutString(" bit writing done ");
    // Check for BNO055_iERROR before proceeding
    BNO055_iERROR = imu_bno055_I2CMasterSendStop(timeoutMs);


    return (s8)BNO055_iERROR;
    }

    s8 BNO055_I2C_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
    {

    s32 BNO055_iERROR = 0; // this is the "status" we usually use in our R/W functions
    u8 idx;

    uint32 timeoutMs = 0;

    BNO055_iERROR = imu_bno055_I2CMasterSendStart(dev_addr, imu_bno055_I2C_WRITE_XFER_MODE,timeoutMs);
    // Check for BNO055_iERROR before proceeding
    BNO055_iERROR = imu_bno055_I2CMasterWriteByte(reg_addr,timeoutMs);
    // Check for BNO055_iERROR before proceeding
    BNO055_iERROR = imu_bno055_I2CMasterSendStop(timeoutMs);

    BNO055_iERROR = imu_bno055_I2CMasterSendStart(dev_addr, imu_bno055_I2C_READ_XFER_MODE,timeoutMs);
    //starts reading the data bit by bit and putting them into a buffer
    for (idx = 0; (idx < cnt) && (BNO055_iERROR == 0); idx++)
    {
    reg_data[idx] = imu_bno055_I2CMasterReadByte(imu_bno055_I2C_ACK_DATA, reg_data, timeoutMs); //stores the byte in an array

    }
    // Check for BNO055_iERROR before proceeding
    //I2C_UART_UartPutString(" bit reading done ");
    BNO055_iERROR = imu_bno055_I2CMasterSendStop(timeoutMs);

    return (s8)BNO055_iERROR;
    }

    3 REPLIES 3

    Minhwan
    Community Moderator
    Community Moderator

    Hello rbtics, 

     

    Your i2c looks like okay, but can't dig into it. 

    Here is my log for BNO055. My suggestion is to check at least your MCU is trying to send BNO055 with 0x28 address. 

    Thanks, 

    Yes I have my dev_addr set to 0x28 and I am still not getting anything. Do you have any recommendations on how I can improve this function?

    Minhwan
    Community Moderator
    Community Moderator

    Hello, 

     

    Please check whether BNO055 hardware is okay. 

    5.2 connection diagram i2c. 

    https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bno055-ds000.pdf

    If hardware connection is okay, at least your MCU should send some data and you should be able to check it thru logic analyzer. 

    Thanks, 

    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