Hello everyone,
My name is Kirtan Soni and I am trying to interface the infineon's KP253 pressure sensor with the arduino mega. So far I have been able to get the output readings from the sensor (not what I need) and I think that I am using the correct SPI protocol as per give data sheet.
I am getting a diag1 error (As per datasheet) in my readings. I will explain what I did in depth below:
This is my circuit diagram. According to the datasheet the KP253 has a 16bit SPI transfer register the protocol is MSB first, 0.1 - 5 MHz clock speed, model 1. I have used the SPI.transfer16() to read and write to the register of the sensor, I am getting the readings and the readings are also changing with the rise and drop of temperature.
To check whether my connection and program is right I also write the identifier code and it gives me proper response as indicated in the datasheet.
This is the output I get by converting it to binary, I get - 0101000100110111 which is correct.
But when I write the temperature read command it gives me - 0101001011000110
So according to the response structure I get Diag1 error - 010
Here is my code:
#include<SPI.h> //Library for SPI
const int CS=4;
volatile int Response;
void setup (void)
{
Serial.begin(115200);
pinMode(CS,OUTPUT);
digitalWrite(CS,HIGH);
}
void loop(void)
{
digitalWrite(CS,LOW);
SPI.begin();
SPCR = (1<<SPE)|(1<<MSTR)|(1<<CPHA);
Response = SPI.transfer16(0b0100000000000000);
digitalWrite(CS,HIGH);
Serial.println(Response);
}
I tried everything that I knew but I don't know what am I doing wrong?
Thank you for your time
I really appreciate your efforts.
To make your efforts a bit easy I am attaching the link to the datasheet as well.
