I'm trying to interface an Arduino Mega with an AD7714 ADC. This ADC requires a command to be sent to the communications register (in my case 0x5C) in order to begin a read from the data register.
My question is how do I receive the data that is transmitted from the Slave ADC to the Master Arduino on the MISO line?
At the moment I have this code in an interrupt that is activated when the DRDY goes low:
byte dataIn;
byte dataOut = 0;
adc_write_reg(0x5C); //tell ADC to read data from data register
dataIn = SPI.transfer(dataOut); //transmit data in order to recieve data??
Thanks!
SPI.transfer()
, close the transaction, then re-establish a SPI transition and set the Comm register with R/W bit as Read, and read in the data with anotherSPI.transfer()
. BTW, don't do I/O data access within your Interrupt function. Keep your Interrupt function as short as possible by just set/reset a status...