Bosch Sensortec Community

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

    Error communicating with BME 680 on STM32WLE

    Error communicating with BME 680 on STM32WLE

    hamady
    Established Member

    Hello,

    After upadting the common.c file to my platform: https://github.com/boschsensortec/BME68x-Sensor-API/tree/master/examples/common

    I have a error in the self test and also i can't read values of temp humidity ect....

    I uplauded files about the schematic, uart debug, code,config SPI 

    Just to know the mosfet use to control the VDD2 is working (3.3V)

    And the SPI in this settings works with my onboard flash (i used seperate CS pin)

    The (uint8_t *)& in spi function was added on the end but with and without nothing change

    Can you help me figure out what is the issue

    Thanks

     

    4 REPLIES 4

    hamady
    Established Member

    Quick note : the BME680 work with arduino IDE and adafruit lib in SPI

    BSTRobin
    Community Moderator
    Community Moderator

    Hi hamady,

    In you SPI read and write function, there are some errors.
    You can change your code to the following code and run it again.

    /*!
    * SPI read function map to COINES platform
    */
    BME68X_INTF_RET_TYPE bme68x_spi_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *intf_ptr)
    {
    APP_LOG(TS_ON, VLEVEL_L, "Read BME 6810 SPI\r\n");
    //uint8_t dev_addr = *(uint8_t*)intf_ptr;
    GTXBuffer[0] = reg_addr | 0x80;
    HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET); // NSS low
    HAL_SPI_TransmitReceive(&hspi1,GTXBuffer,GRXBuffer,len+1, 1000);
    while(&hspi1 == HAL_SPI_STATE_BUSY); // wait for xmission complete
    for(uint32_t i=0;i<len;i++){
    APP_LOG(TS_ON, VLEVEL_L, "DATA [%d]=%x\r\n",i,GRXBuffer[i]);
    }
    memcpy(reg_data, GRXBuffer+1, len);


    HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET); // NSS high
    return HAL_OK;
    }

    /*!
    * SPI write function map to COINES platform
    */
    BME68X_INTF_RET_TYPE bme68x_spi_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len, void *intf_ptr)
    {
    APP_LOG(TS_ON, VLEVEL_L, "Write BME 6810 SPI\r\n");
    //uint8_t dev_addr = *(uint8_t*)intf_ptr;
    GTXBuffer[0] = len & 0x7F;
    memcpy(&GTXBuffer[1], reg_data, len);
    HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET); // NSS low
    HAL_SPI_Transmit(&hspi1, GTXBuffer,len+1, 1000);
    while(&hspi1 == HAL_SPI_STATE_BUSY); // wait for xmission complete
    HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET); // NSS high
    return HAL_OK;
    }

    hamady
    Established Member

    Finally issue resolved :

    In the write function for SPI i wrote len&0x7F instead of :

    GTXBuffer[0] = reg_addr & 0x7F;

    Thanks for the help

     

    BSTRobin
    Community Moderator
    Community Moderator

    Welcome, hamady.

    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