I am prototyping a design using the LTC1859, a SPI ADC.
I've done lots of SPI development before, using full duplex mode, transmitting a byte via MOSI and simultaneously receiving a byte via MISO. This is how I intend to communicate with this device.
I'm not clear from the examples provided how to read the received byte that results from transmitting a byte. My code currently looks like this below. My calling SPI.transfer() seems to hang execution, and the next line never gets executed. (I've upgraded to IDE 1.6.6 as my previous installation, as 1.0.5 would not compile any SPI library calls!)
#include <SPI.h>
// define ADC comms pin names as digital pin numbers to suit project. DI = data into MCU; DO = data out of MCU
#define nBUSY 2 // DI, ADC converter status: 0=busy, 1=done
#define nRD 6 // DO, enable ADC SDO: 0=enable, 1=disable
#define CONVST 7 // DO, ADC start conversion: 1=go
// SPI lib takes care of data & clock lines, now attached to MISO, MOSI and SCK lines, for shield compatibility
void setup() {
// digital IO
// ==========
pinMode(nBUSY, INPUT);
pinMode(nRD, OUTPUT);
pinMode(CONVST, OUTPUT);
// start the SPI library:
SPI.beginTransaction(SPISettings(16000000, MSBFIRST, SPI_MODE0));
}
void loop() {
byte receivedData = SPI.transfer(0b10101010);
digitalWrite(13, !(digitalRead(13))); // toggle PCB LED // <--- never gets this far! why?!?!?
}
Many thanks if you can help me.
Matt