I am having trouble transferring my Due Code to the Nucleo H743ZI.
To read out three BMA280 accelerometers with the same SPI instance, I need to manually configure the CSs.
By reading out register 0x00 ChipID I can evaluate the connection: Two of the CS are working, the third yields an irregular value which I can not figure out. While CS_1 and CS_2 are constantly yielding the fixed value "251", CS_3 often reveives false values, e.g. 246 or 247, but not constantly. Running the same lines again can lead to these outputs:
Code: Select all
S3 246
S3 246
S3 251
S3 251
S3 251
S3 246
S3 251
S3 251
S3 251
Pins I've tried for CS_3 are:
- PF12, since it is a general I/O pin
- PA0, since the other pins on timer functions work as well
- PA4, since it is a designated CS pin, although for SPI_B
This is the part of the code I am having trouble with:
Code: Select all
#include <SPI.h>
const uint8_t CS_1 = PD14;
const uint8_t CS_2 = PD15;
const uint8_t CS_3 = PA0;
byte readData[6];
void setup() {
pinMode(CS_1, OUTPUT);
pinMode(CS_2, OUTPUT);
pinMode(CS_3, OUTPUT);
Serial.begin(115200);
SPI.begin();
SPI.beginTransaction(CS_1, SPISettings(SPI_CLOCK_DIV4, MSBFIRST, SPI_MODE0));
SPI.beginTransaction(CS_2, SPISettings(SPI_CLOCK_DIV4, MSBFIRST, SPI_MODE0));
SPI.beginTransaction(CS_3, SPISettings(SPI_CLOCK_DIV4, MSBFIRST, SPI_MODE0));
//Reading out register 0x00 in read mode --> 0x00 | 0x80
SPI.transfer(CS_1, 0x80, SPI_CONTINUE);
readData[0] = SPI.transfer(CS_1, 0x00, SPI_LAST);
Serial.print("Manual read out S1: ");
Serial.println(readData[0]);
SPI.transfer(CS_2, 0x80, SPI_CONTINUE);
readData[0] = SPI.transfer(CS_2, 0x00, SPI_LAST);
Serial.print("Manual read out S2: ");
Serial.println(readData[0]);
SPI.transfer(CS_3, 0x80, SPI_CONTINUE);
readData[0] = SPI.transfer(CS_3, 0x00, SPI_LAST);
Serial.print("Manual read out S3: ");
Serial.println(readData[0]);
}
Any tips, links, documentations, ... would be great, thanks for you help!