Post Go back to editing

AD7768-4 DOUT interface problem


I read a few answers about this but I am still unable to properly read the data output from the AS7768-4. I use STM32F730Z8 and I use SPI4 interface in read only slave mode with software NSS. The SPI is configured as follows:

I tried a few different combinations of settings but without success.

The ADC uses a 32.768 MHz crystal (ABMM2-32.768MHZ-E2F-T) as a clock source. CLK_SEL, FORMAT0 and PIN/SPI are all pulled up with 10k resistors and FILTER/GPIO4 is pulled up when the MCU initializes. The DRDY signal is used as an external interrupt (I tried both on rising and falling edge) for the STM32 as a trigger to start reading the data. The MCU SYSCLK is 216 MHz.

For ADC setup I first pulse the reset pin (0 -> wait 2 ms -> 1 -> wait 10 ms) and I then write to the following registers:

  • 0x01 - value 0x0C
  • 0x04 - value 0x33
  • 0x0E - value 0x80

All other registers are left at their default values.

I then read the status register and I read a value 0. Next I pulse the start pin  (0 -> wait 110 ns -> 1) and read the status register again which still returns 0. On ADC the SYNC_IN is connected to SYNC_OUT and the START pin is connected to the MCU.

I also tried manually setting the software NSS as it is always low by default so that the SPI interface would only be active for reading the data but that didn't change anything.

I looked at the DOUT0, DCLK and DRDY signals with a logic analyser and the timings are what I calculated they should be:

I didn't check if the values taken with the scope correspond to what I send via USB yet but just looking at it it isn't what I would expect. I do have a matlab figure also available since it is difficult to read anything from the pictures.

For the 2 pictures above I also set the following registers:

  • 0x56 - value 0x33
  • 0x57 - value 0x05

This is the schematic for the ADC part:

Did I miss something? Can you please help me with reading the data. I am not sure if I set the STM32 correctly but looking at the DOUT signal it also doesn't look right to me especially with the test mode on.

Kind regards

  • thanks for the detailed email 

    firstly could be make sure that the SPI registers are getting written? you can try reading non zero values to and Confirm.

    i think your wave form looks correct to me .. you have serialized all data appearing on DOUT0

    the DRDY signal is also coming @ 16ksps, is this intended?

  • Sorry for the late reply. I didn't seem to get a reply notification even though it it enabled.

    I did try and read the registers before and they were at correct value. I did this at the beginning to make sure I am writing correctly to the ADC. I can read them again to see if the values are the same as expected.

    I calculated that the time between DRDY signals should be 62.4us (16kHz) which is correrct. I actually need just 2 channels for my application but I enabled all 4 just in case. I know that channel 2 must be enabled as I use an external crystal. Once I am getting the correct values I will put channel 3 in to standby.

    This is an example of values I read on the DOUT0 pin:

    I read the data in to a 8 bit array so on the left is [0] and on the right is [15]. The right most value which is always 0 is the return from STM32 HAL function for SPI read and it means OK. I am not sure but all of the data may be shifted for 1 bit. I will need to make some adjustments to the program and check this.

    However I read this values now that the ADC is set in diagnostic mode (register 0x56 has a value of 0x33 and 0x57 value of 0x05). They don't look right to me. I would expect that the values would be close to 0x000000 and the left most value should be the header for CH0.

    At the beginning I did incorrectly set a few registest of the ADC. Could that be a problem in any way? Are the MODE pins also used in SPI control? I do have GPIO4 pulled up by the MCU. Bot others are set as inputs on both sides (ADC and MCU).

    For example I wrote a value of 0x1B in to register 0x04 which is not a valid option. And in register 0x05 I didn't set to 1 bit 3 which should be set to 1.

    When I had the clock settings misconfigured it did show up in the status register.

  • I have read all of the registers after the start input signal pulse. The values are in the .txt document I attached. It looks like the values I wrote are ok.

    Do the values seem ok?

    The first number is the register address and the second the register value.

    I still need to check if I am reading correctly or if all my data is shifted for 1 clock period.

    SPI REG 0x00: 0x00
    SPI REG 0x01: 0x0c
    SPI REG 0x02: 0x00
    SPI REG 0x03: 0x00
    SPI REG 0x04: 0x33
    SPI REG 0x05: 0x08
    SPI REG 0x06: 0x80
    SPI REG 0x07: 0x00
    SPI REG 0x08: 0x00
    SPI REG 0x09: 0x00
    SPI REG 0x0a: 0x06
    SPI REG 0x0b: 0x00
    SPI REG 0x0c: 0x00
    SPI REG 0x0d: 0x00
    SPI REG 0x0e: 0x80
    SPI REG 0x0f: 0x00
    SPI REG 0x10: 0x13
    SPI REG 0x11: 0xff
    SPI REG 0x12: 0xff
    SPI REG 0x13: 0x00
    SPI REG 0x14: 0x00
    SPI REG 0x1e: 0x00
    SPI REG 0x1f: 0x00
    SPI REG 0x20: 0x00
    SPI REG 0x21: 0x00
    SPI REG 0x22: 0x00
    SPI REG 0x23: 0x00
    SPI REG 0x24: 0x00
    SPI REG 0x25: 0x00
    SPI REG 0x26: 0x00
    SPI REG 0x27: 0x00
    SPI REG 0x28: 0x00
    SPI REG 0x29: 0x00
    SPI REG 0x2a: 0x00
    SPI REG 0x2b: 0x00
    SPI REG 0x2c: 0x00
    SPI REG 0x2d: 0x00
    SPI REG 0x2e: 0x00
    SPI REG 0x2f: 0x00
    SPI REG 0x30: 0x00
    SPI REG 0x31: 0x00
    SPI REG 0x32: 0x00
    SPI REG 0x33: 0x00
    SPI REG 0x34: 0x00
    SPI REG 0x35: 0x00
    SPI REG 0x36: 0x55
    SPI REG 0x37: 0x55
    SPI REG 0x38: 0xcd
    SPI REG 0x39: 0x55
    SPI REG 0x3a: 0x55
    SPI REG 0x3b: 0x45
    SPI REG 0x3c: 0x50
    SPI REG 0x3d: 0x00
    SPI REG 0x3e: 0x05
    SPI REG 0x3f: 0x50
    SPI REG 0x40: 0x00
    SPI REG 0x41: 0x05
    SPI REG 0x42: 0x55
    SPI REG 0x43: 0x55
    SPI REG 0x44: 0xa5
    SPI REG 0x45: 0x55
    SPI REG 0x46: 0x52
    SPI REG 0x47: 0x75
    SPI REG 0x48: 0x50
    SPI REG 0x49: 0x00
    SPI REG 0x4a: 0x05
    SPI REG 0x4b: 0x50
    SPI REG 0x4c: 0x00
    SPI REG 0x4d: 0x05
    SPI REG 0x4e: 0x00
    SPI REG 0x4f: 0x00
    SPI REG 0x50: 0x00
    SPI REG 0x51: 0x00
    SPI REG 0x52: 0x00
    SPI REG 0x53: 0x00
    SPI REG 0x54: 0x00
    SPI REG 0x55: 0x00
    SPI REG 0x56: 0x33
    SPI REG 0x57: 0x05
    SPI REG 0x58: 0x02
    SPI REG 0x59: 0x0a

  • Hi

    what the data snapshot you have sent - is it with zero input?

    Hope you have toggled the SYNC bit to low and then high after you have done writing to the SPI registers

    1 experiment is to switch inputs in ADC diagnostic control register from zero to positive to negative and see the output for these 3 inputs.

    Secondly while doing this test make sure the inputs are completely disconnected.


  • I can't disconnect the inputs to CH0 and 1 as they are directly connected to pressure sensors on my PCB. So I now only set CH2 and 3 for diagnostic mode at  zero voltage level.

    I don't use the SYNC pins but I toggle the the START pin low.

    This is an example of what I get on DOUT line:

    Is now looks ok to me.

    I still don't read the data correctly with STM32 but I think this is not the correct forum for solving that problem. The problem I am having with STM32F730 (216 MHz clock) is the high latency of interrupt execution so it misses the first 7 clock cycles.

    Thank you for help.