Arduino Due with LTC2366 ADC

I am using Arduino Due’s SPI (MISO) interface to communicate with an LTC2366 16 bit ADC (edit: it is 12 bit).

I am using the suggested libraries and yet I see all 1s in mu output. This is the code I’m using:

#include <SPI.h>
#include <Arduino.h>
#include <Wire.h>
#include <LTC2366.h>

uint16_t val;
uint16_t *ptrVal=&val;
float final; 

void setup(){



  pinMode(MISO, INPUT);

  SPI.setClockDivider(10, 42);

  SPI.beginTransaction(SPISettings(16000000, MSBFIRST, SPI_MODE1));


void loop(){

  final = LTC2366_code_to_voltage(val,3.3);

  //transfer 0x0F to the device on pin 10, keep the chip selected
  // val= SPI.transfer16(10);
  //transfer 0x00 to the device on pin 10, keep the chip selected
  //transfer 0x00 to the device on pin 10, store byte received in response1, keep the chip selected


Where the functions used are defined as follows:

// Reads and sends a word
// Return 0 if successful, 1 if failed
void spi_transfer_word(uint8_t cs_pin, uint16_t tx, uint16_t *rx)
        uint8_t b[2];
        uint16_t w;
    } data_tx;
        uint8_t b[2];
        uint16_t w;
    } data_rx;

    data_tx.w = tx;

    output_low(cs_pin);                         //! 1) Pull CS low

    data_rx.b[1] = SPI.transfer(data_tx.b[1]);  //! 2) Read MSB and send MSB
    data_rx.b[0] = SPI.transfer(data_tx.b[0]);  //! 3) Read LSB and send LSB

    *rx = data_rx.w;

    output_high(cs_pin);                        //! 4) Pull CS high

// Reads the ADC  and returns 16-bit data
void LTC2366_read(uint8_t cs, uint16_t *ptr_adc_code)
  uint16_t dummy_command = 0;

  spi_transfer_word(cs, dummy_command, ptr_adc_code);



// Calculates the voltage corresponding to an adc code in offset binary, given the reference voltage (in volts)
float LTC2366_code_to_voltage(uint16_t adc_code, float vref)
  float voltage;

  adc_code = adc_code << 2;  //the data is left justified to bit_13 of a 16 bit word

  voltage = (float)adc_code;
  voltage = voltage / (pow(2,16)-1);    //! 2) This calculates the input as a fraction of the reference voltage (dimensionless)
  voltage = voltage * vref;           //! 3) Multiply fraction by Vref to get the actual voltage at the input (in volts)


NO VALUE IS PRINTED. THE code makes so much sense, can you please help me understand what I am missing.

LTC2366 datasheet states that it’s an 12-bit ADC converter…

Thank you for that, It was a typo. Still the issue stands

SPI.begin() should set up the hardware pins for SPI peripheral use. You should not call pinMode() after SPI.begin() because it will make MISO a regular GPIO pin again.


Thank you for your time. I get extremely noisy data even for DC values. I do not understand why that is.

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