SPI communication with MLX75306

Good Day,

I am having some trouble talking to an optical sensor array with SPI (MLX75306, data sheet at: https://www.melexis.com/-/media/files/documents/datasheets/mlx75306-datasheet-melexis.pdf). I am using an Arduino Nano Every. I am not familiar with SPI communication and I have the feeling I am missing something essential in the communication protocol. I attached an interrupt to the frameready pin of the optical array, but this interrupt never gets triggered. From what I understand from the datasheet, sending the “Start Integration” command should result in Frameready going high after a set time. I have got my Arrduino connected to the MLX75306 as follows:
Arduino —> MLX75306:

D12/MISO → MISO
D11/MOSI → MOSI
D13 → SCLK
D6 → Frameready
D5 → CS
+3V3 → pin 5 & 6 (3v3)
GND → pin 4 (GND)
with a 1muF and .1muF in parallel between pin 4 and pin 5 on the MLC75306.

This is the arduino code (I am not doing a detailed read out of the sensor yet, this code is mainly to get the interrupt to trigger):

#include <SPI.h>

const int dataReadyPin = 6;
const int chipSelectPin = 5;
const byte MLX75306_CR = 0b11110000;   // chip reset
const byte MLX75306_SI = 0b10111000;   // start integration
const byte MLX75306_RO8 = 0b10011001; //Read 8bit
const byte MLX75306_SM = 0b11000110; // Sleep Mode
const byte MLX75306_WU = 0b11000011; // Wake UP
const byte TIME_INT_MSB = 0b01001110; // MSB+LSB is one 16 bit byte
const byte TIME_INT_LSB = 0b00100100; //current value 20000, for 10 ms integration time
int i = 0;

void setup() {
  
  SPI.begin();
  Serial.begin(115200);
  pinMode(dataReadyPin, INPUT);
  pinMode(chipSelectPin, OUTPUT);

  initiate();
  start();
  sleep();
  attachInterrupt(digitalPinToInterrupt(dataReadyPin), ReadData, RISING);
}

void loop() {
  byte inByte = 0;
  initiate();
  start();
  acquire_8b();
  Serial.println("Sent");
  delay(2000);


}
void initiate()
{
  SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE3));
  digitalWrite (chipSelectPin, LOW);
  SPI.transfer(MLX75306_CR);
  SPI.transfer(0x00);
  SPI.transfer(0x00);
  digitalWrite (chipSelectPin, HIGH);
  SPI.endTransaction();
}

void start()
{
  SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE3));
  digitalWrite (chipSelectPin, LOW);
  SPI.transfer(MLX75306_WU);
  SPI.transfer(0x00);
  SPI.transfer(0x00);
  digitalWrite (chipSelectPin, HIGH);
  SPI.endTransaction();
}
void sleep()
{
  SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE3));
  digitalWrite (chipSelectPin, LOW);
  SPI.transfer(MLX75306_SM);
  SPI.transfer(0x00);
  SPI.transfer(0x00);
  digitalWrite (chipSelectPin, HIGH);
  SPI.endTransaction();
}

void acquire_8b()
{
  SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE3));
  digitalWrite (chipSelectPin, LOW);
  SPI.transfer(MLX75306_SI);
  SPI.transfer(TIME_INT_MSB);
  SPI.transfer(TIME_INT_LSB);
  digitalWrite (chipSelectPin, HIGH);
  SPI.endTransaction();
}

void ReadData()
{
  byte inByte;
  SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE3));
  digitalWrite (chipSelectPin, LOW);
  SPI.transfer(MLX75306_RO8);
  SPI.transfer(0x02);
  SPI.transfer(0x8F);
  inByte = SPI.transfer(0x00);
  digitalWrite (chipSelectPin, HIGH);
  SPI.endTransaction();
  Serial.println(inByte, BIN);
}

Many thanks!

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