SPI Issue working with the ADS8684 - Page 1
Forum section: electronics / projects

author: Dudogama
author_rank: Newbie
timestamp: January 23, 2025, 07:11:22 am
content: I am currently working on a project for my masters degree and I ran int a problem. I am using an Arduino Portenta H7 as interface between a PC and an ADC. The data transfers via SPI and goes through a digital isolator. I am trying to read some of the registers of the ADC, but I only receive 0xFF as answer.I have use multiple reference projects using the same ADC without any progress and I am not sure, if the Problem lies in the Software or the Hardware. The ADC is soldered onto the PCB and is not easy to remove, so I can`t really test it in isolation. Any help would be much appreciated.The full circuit Layout and Pin assignment is attached.This is the code, i have been using to read the most basic registers to verify the functionallity written in Arduino IDE attached to this postThx for your help :)

author: moffy
author_rank: Super Contributor
timestamp: January 23, 2025, 07:49:00 am
content: Looking at the datasheet page 46, to read a register /CS goes low, then an 8 bit address is sent with the MSB set to 0 then a 16 bit read takes place and /CS goes high.Your code:Code:uint16_t readRegister(uint8_t regAddr) {uint16_t command = (regAddr << 8);digitalWrite(CS_PIN, LOW);SPI.transfer16(command);digitalWrite(CS_PIN, HIGH);digitalWrite(CS_PIN, LOW);uint16_t data = SPI.transfer16(0x0000); // Dummy write to readdigitalWrite(CS_PIN, HIGH);return data;}seems to be a 16 bit write for the address /CS low then /CS high, then a 16 bit read /CS low then /CS high, not the same.

author: ledtester
author_rank: Super Contributor
timestamp: January 23, 2025, 08:02:54 am
content: You can wrap your code in [code ] blocks - it'll be easier to read.Here is what seems to be the pin and signal assignments:Code:Function Arduino Net Name ISOW ADCSCLK D9 (18) ADC_CLOCK INB (4) SCLK (37)CS D7 (16) SPI_SS INA (3) CS_N (38)MISO D8 (17) INC_NC INC (5) SDI (1)MOSI D10 (19) ADC_OUT OUTD (6) SDO (36)Pin number are in parentheses. Please check and see if I have made any mistakes.If these are the assignments then I think that MISO on the Arduino should be connected to the ADC_OUT net and MOSI connected to INC_NC.Also, have a look at these discussions:https://forum.arduino.cc/t/minimal-example-of-spi-for-portenta-h7/695207/2https://github.com/arduino/ArduinoCore-mbed/issues/131

author: moffy
author_rank: Super Contributor
timestamp: January 23, 2025, 08:04:30 am
content: Perhaps for code something like this:Code:uint16_t readRegister16(uint8_t regAddr){uint16_t data;regAdrr = regAddr & 0x07f;digitalWrite(CS_PIN, LOW);SPI.transfer8(regAddr);data = SPI.transfer16(0x0000); // Dummy write to readdigitalWrite(CS_PIN, HIGH);return data;}

author: Dudogama
author_rank: Newbie
timestamp: January 23, 2025, 09:13:55 am
content: Thx for your reply, unfortunatly the Code is not working so far.

author: Dudogama
author_rank: Newbie
timestamp: January 23, 2025, 09:27:41 am
content: Thx for your reply.I think you accidently switched MISO (D10) and MOSI (D8).

author: BennoG
author_rank: Frequent Contributor
timestamp: January 23, 2025, 09:31:23 am
content: this is where a scope would be of great value.Benno

author: Dudogama
author_rank: Newbie
timestamp: January 23, 2025, 01:23:01 pm
content: I scoped the SPI Bus, while sending increasing +1 (loop) Hex Values. There is something going on with the SPI_MODE1 setting. The last bit stays at HIGH till the start of the next loop cycle, with many false data in between (0xFF....).Code and screens are attached.

author: ledtester
author_rank: Super Contributor
timestamp: January 23, 2025, 03:00:36 pm
content: I have a question about this code:Code:// Configure reset pinpinMode(reset_PIN, OUTPUT);digitalWrite(reset_PIN, HIGH); // reset ADCDoes it affect the ADS8684?

author: Dudogama
author_rank: Newbie
timestamp: January 23, 2025, 03:43:13 pm
content: If the Reset Pin is not pulled HIGH via a pull-up resistor or set to HIGH in software, it will not function correctly.We initially forgot to add a pull-up resistor, but a 3.6 V HIGH can still be achieved with these code lines.

author: Dudogama
author_rank: Newbie
timestamp: January 23, 2025, 03:49:31 pm
content: Another major issue has arisen.We analyzed the SPI bus signals before and after passing through the digital isolator (ISOW7841) using an oscilloscope. The signal quality is extremely poor, and some bits fail to meet the HIGH-level threshold for the ADS8684, showing values of only 2.5–3 V. This is evident in the attached images: "Before_iso_INC(MOSI)" and "After_iso_INC(MOSI)".At this point, the only potential fix I can think of involves modifying the voltage levels. The same goes for the CLK.

author: Dudogama
author_rank: Newbie
timestamp: January 23, 2025, 05:16:39 pm
content: We forgot to connect the Picoscope ground (GND) to the isolated ground (GND) of the board. I'll take measurements again tomorrow—hopefully, I can find the solution then. Thanks for all your responses today!

author: ledtester
author_rank: Super Contributor
timestamp: January 23, 2025, 05:22:43 pm
content: Quote from: Dudogama on January 23, 2025, 03:43:13 pmIs this signal from the Arduino also isolated?

author: moffy
author_rank: Super Contributor
timestamp: January 23, 2025, 09:23:55 pm
content: If you lower your SPI clock to 1MHz you have a better chance of checking the logic of the code and comms without signal corruption. Once you get it working at the lower frequency you can then up the frequency and deal with any signal corruption/timing issues with the confidence that at least the code is correct.