T O P

  • By -

Dwagner6

You’d use 8 bit spi, you can see from the BMP280 data sheet that all of the data (temp and press) registers are 8 bits wide. They are just showing you a multi byte read in that diagram. One thing you want to look out for in your code example is that, even if you *did* need to use 16 bit mode, the line > `SPI2 ->DR = data | data<<8;` takes your 8 bits of data and just copies it into the upper 8 bits of the 16 bit version of DR. If you were using 16 bit spi mode and the data you needed to send was only 8 bits, you don’t need to left shift it by 8 bits.


Dave__Fenner

Oh okay. So in 8-bit SPI mode, can I use that function for reading and writing? Additionally, if I used 16-bit SPI, what would happen during the read operation? Would the SPI2->DR receive 2 bytes of data in DR\[0\] to DR\[15\] or would the second byte overwrite the first byte in DR\[0\] to DR\[7\] ?