ATMega328P and BMP388 data processing questions

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm trying to read data from a BMP388 using Bosch drivers and SPI 4-wire mode. I have used a logic analyzer to determine that the sensor is responding to my burst read request with the expected first transmission of a dummy byte, then the transmission of 6 bytes - the first 3 being pressure data and the last three being temperature data. I am transmitting dummy bytes to the device to keep the clock rolling.

 

The data is captured in an array and some processing done to the values by the Bosch driver.

 

The issue I'm running into now is that I am unable to print this data in a form that "makes sense", leading me to believe that my understanding of how to get these floating point values printed needs another set of eyes.

 

I have tried the following methods to print the data:

 

printf - I have followed tutorials to get printf to print via UART and display on my desktop. I have also followed tutorials to make printf print floating point values.

 

printf("Temperature\t Pressure\t\n");
printf("%0.2f\t\t %0.2f\t\t\n",data.temperature, data.pressure);

 

Using the above the following prints:

 

Temperature     Pressure    
0.00                 0.00

 

If I change the printf statements to use the integer format specifier %d I receive the following:

 

Temperature     Pressure    
14259              0

 

These results are especially odd to me since I get to following if I try an itoa() conversion, my understanding is that this would simply truncate a floating point number:

 

string_transmit("Temperature\t");

string_transmit(itoa(data.temperature, buffer, 10));

string_transmit("Pressure\t");
string_transmit(itoa(data.pressure, buffer, 10));
 

Temperature    14259

Pressure          -26323

 

Can someone offer advice on a better way to determine what I've actually got stored in data.temperature and data.pressure? Or offer advice on how I could further go about debugging this situation?

 

I've attached the logic analyzer picture, but the raw data isn't helpful since the bosch driver makes numerous compensation calculations after the transmission.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

3 byte floats? what format is that?  ieee754 floating point is 4 bytes.

 

Have you considered the data is sent little endian so your data order is backwards?

or even LSB first?

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274

 

 

 

Last Edited: Thu. Jul 11, 2019 - 09:08 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Mother of God the BMP388 datasheet is a terrible document but I eventually reeached the bit where it said:

 

 

Therefore forget itoa() and use ultoa() and see what happens.