I am using Arduino mega to interface with Infineon KP253 pressure sensor and I need some help with it

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 :smile: I really appreciate your efforts.
To make your efforts a bit easy I am attaching the link to the datasheet as well.

You should probably not "go behind the library's back" and change the SPCR register.

See:
https://www.arduino.cc/reference/en/language/functions/communication/spi/spisettings/
or
https://www.arduino.cc/reference/en/language/functions/communication/spi/setdatamode/
https://www.arduino.cc/reference/en/language/functions/communication/spi/setbitorder/
and
https://www.arduino.cc/reference/en/language/functions/communication/spi/setclockdivider/

1 Like

Welcome.

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project :wink: See About the Installation & Troubleshooting category.

1 Like

Hello john,

I also tried it with the normal library commands but still it has the same results :slight_smile:

Thank you.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.