1

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!

5
  • It seems like your more wondering the what and why of the sent data when your goal is to receive data. Is that the case?
    – timemage
    Feb 10, 2021 at 14:24
  • I'm not sure what you mean by the what and why :/ Simply put all I need to do is store the data recieved on the MISO line in a variable Feb 10, 2021 at 14:46
  • Typically you need to do two SPI transactions, one for Writing data by setting the R/W bit of the Comm register to Write, and write the data with 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 another SPI.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...
    – hcheung
    Feb 10, 2021 at 14:55
  • The write is to send the command, the read is to get the data. Here is a library that I'm familiar for another ADI chip with similar mechanism that you could take a look on how the code looks like.
    – hcheung
    Feb 10, 2021 at 15:03
  • Sending 0x5c is just to tell the chip you want to read the data register. You can ignore the this first received byte. You then send two or three zero bytes (0x00), to get your 16-bit or 24-bit ADC result.
    – Gerben
    Feb 10, 2021 at 15:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.