Author Topic: Sending 24-bit frames via SPI using Arduino Uno  (Read 354 times)

0 Members and 1 Guest are viewing this topic.

Offline aiq25

  • Regular Contributor
  • *
  • Posts: 239
  • Country: us
Sending 24-bit frames via SPI using Arduino Uno
« on: September 23, 2021, 02:36:16 pm »
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.
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2045
  • Country: us
Re: Sending 24-bit frames via SPI using Arduino Uno
« Reply #1 on: September 23, 2021, 03:32:05 pm »
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.
 

Offline voltsandjolts

  • Supporter
  • ****
  • Posts: 1366
  • Country: gb
Re: Sending 24-bit frames via SPI using Arduino Uno
« Reply #2 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'!!
« Last Edit: September 23, 2021, 03:43:48 pm by voltsandjolts »
 
The following users thanked this post: aiq25

Offline aiq25

  • Regular Contributor
  • *
  • Posts: 239
  • Country: us
Re: Sending 24-bit frames via SPI using Arduino Uno
« Reply #3 on: September 23, 2021, 07:33:34 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'!!

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


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf