Electronics > Microcontrollers

Sending 24-bit frames via SPI using Arduino Uno

(1/1)

aiq25:
Hi guys,

I'm trying to interface with an ADS7038 8-channel ADC IC. I'm trying to interface it to an Arduino Uno. This device works with 24-bit frames SPI (3 bytes). Unforunately I'm having all sorts of issues getting the IC to configure correctly but I think one of the issues I'm seeing is that the data being sent to the ADS7038 is not in the format it's expecting to be. I have the Arduino configured for 200kHz.

I am trying to read some registers upon power up of the IC. I have attached a screenshot of what the SPI message should be according to the datasheet.

Also attached is the Arduino SPI frame. I haven't done SPI communication in a long time and don't remember doing multi-byte SPI frames so I'm not sure if this looks correct. CH1 is the CS, CH2 is MOSI, CH3 is MISO, and CH4 is SCLK. Does the MOSI frame seem correct? Arduino is supposed to send the following bytes:  0b00010000, 0x00, 0x00. I see on the MOSI line after the first 8-bits, the line goes HIGH for then comes back then. Is this standard for SPI or should all the bits, even after the first byte stay LOW (5V) (since the next 2 bytes being sent are 0x00's)? Not sure if this transition after the first byte is causing the IC any issues.

MarkF:
The first thing to verify is that you have the correct SPI protocol selected.
I don't do much Arduino programming.  So, you will need to check that the clock and sample time meets the A/D requirement (Figure 2 in the datasheet).

   

The second thing is that the order you are sending is the MSB bit first.

Finally, that you are sending the correct commands remembering that you always receive a byte for each byte sent.

voltsandjolts:
The ADC should be reading in data on the rising clock edge (by default at power on) so those little glitches should not matter, since they are away from the rising clock edges.
At first glance, I'd say it looks good. Yeh, double check bit order and CPOL/CPHA settings in the arduino.

Edit: I meant not matter, I missed out the 'not'!!

aiq25:

--- Quote from: voltsandjolts on September 23, 2021, 03:35:02 pm ---The ADC should be reading in data on the rising clock edge (by default at power on) so those little glitches should not matter, since they are away from the rising clock edges.
At first glance, I'd say it looks good. Yeh, double check bit order and CPOL/CPHA settings in the arduino.

Edit: I meant not matter, I missed out the 'not'!!

--- End quote ---

Thanks. I ended up getting the module to FINALLY work!

Navigation

[0] Message Index

There was an error while thanking
Thanking...
Go to full version