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.

asked Feb 27, 2021 at 10:21

1 Answer 1

2

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);
answered Feb 27, 2021 at 10:27
1
  • Turns out the bug was elsewhere in my code. This works fine. Thanks! Commented Feb 27, 2021 at 13:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.