05-11-2023 08:18 PM - edited 05-11-2023 08:24 PM
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
Solved! Go to Solution.
05-11-2023 10:43 PM
Quick note : the BME680 work with arduino IDE and adafruit lib in SPI
05-12-2023 05:00 AM
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(>XBuffer[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;
}
05-12-2023 09:05 AM - edited 05-12-2023 09:50 AM
Finally issue resolved :
In the write function for SPI i wrote len&0x7F instead of :
GTXBuffer[0] = reg_addr & 0x7F;
Thanks for the help
05-12-2023 12:11 PM
Welcome, hamady.