1

I'm working on a driver for an SPI device that returns some data (device status) while the command byte is still being written. Is there a way to read this status data using standard Arduino APIs or do I need to bit-bang to access it?

Here's what the SPI signals look like:

SPI timing diagram

The 6 bits in red are the ones I'm interested in reading.


For context, the device in question is a Microchip MCP3561 ADC (MCP3X6X series). It has a bug (erratum 2) where the new-data-ready flag (/DR_STATUS) is not always set correctly. Part of the work-around involves reading the status bits mentioned above.

3

The SPI.transfer() method is designed to send a byte through the SPI port and, at the same time receive an incoming byte.

Usage pattern:

uint8_t byte_to_send = ...;
uint8_t received_byte = SPI.transfer(byte_to_send);
1
  • Turns out the bug was elsewhere in my code. This works fine. Thanks! – Alex Hajnal Feb 27 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.