I'm pretty new to SPI communication and trying to figure out how to communicate with a magnetic encoder. Now, I would just like to read out the warning and error bits from the encoder. I use pins 13-11 for SCK, MISO, MOSI as shown in the Image. Additionaly I have 3.3 V on the MSEL- Pin to select SPI communication Interface on the encoder as stated in the datasheet. Her is the datasheet: https://docs.broadcom.com/doc/AEAT-9922-Q24-10-to-18-Bit-Programmable-Angular-Magnetic-Encoder-IC-AN. What do I have to change in order to sucessfully read the Error Bits from the Address 0x21 as stated in the Datasheet Page 5?
#include <SPI.h>
const int slaveSelectPin = 10; // Define Slave Select Pin
void setup() {
Serial.begin(9600);
pinMode(slaveSelectPin, OUTPUT);
SPI.begin();
SPI.setBitOrder(MSBFIRST); // Define Data Structure
SPI.setDataMode(SPI_MODE1); // Define SPI Mode for CPOL = 0 and CPHA = 1
digitalWrite(slaveSelectPin, LOW); //Start Communication
SPI.transfer(0x21); //Sending Addredss for Read
unsigned int error = SPI.transfer(0x00);
digitalWrite(slaveSelectPin, HIGH); //End Communication
Serial.println(error);
}
void loop() {
}
Thanks a lot for everyone's help!