Post Go back to editing


Hellow! I have problem with AD4020 ADC. I use it with STM32F407 control, and it's don't answer? What i do wrong? 

My code for STM32

SPI1->CR1 = (0<<0)| //CPHA
(0<<1)| //CPOL
(1<<2)| //MSTR
(5<<3)| //Baund rate
(0<<6)| //SPI Enable
(0<<7)| //LSV first
(1<<8)| //SSI
(1<<9)| //soft CS
(0<<10)| // Full duplex
(1<<11)| // 16 bit
(0<<12)| // CRC data phase
(0<<13)| // CRC disable
(0<<14)| // 3 wire setup
(0<<15); // 4/3 wire setup

while(SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_TXE)!= SET) {};

while(SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_TXE)!= SET) {};

Adding tags for internal tracking purposes
[edited by: tschmitt at 1:44 PM (GMT 0) on 24 Feb 2020]
  • I found that when the SDO signal is disconnected from the SPI bus , some data appears on the output

  • Hi Wyrm,

    Thank you for your question.

    The CNV, SCK and SDI (MOSI) signals in both of your screenshots look good to me. I did notice that in your first screenshot, it looks like you are writing to the AD4020 configuration register, while in the second screenshot you are reading back conversion results. Do you see the same error with MISO if you reconnect SDO to the SPI bus and perform an ADC conversion (like you have in screenshot 2)?

    I suggest for now you debug the SPI with only register writes and reads (figures 49 and 50 in the AD4020/21/22 data sheet). The reason I suggest this is because we can expect a more predictable result on MISO when reading from the register. Can you please try reading from the configuration register with the SDO disconnected + reconnected to the SPI bus and let me know if it worked?

    Another question: how many devices do you have sharing this SPI bus?



  • Good afternoon! Thanks for the answer.I found that disconnecting the logic analyzer from the line,stm32 begins to receive signals. Perhaps this is due to the fact that the ADC produces a current of 500 μA and sometimes this is not enough for the line, maybe I'm wrong. In the first picture that I attached to the post, I tried to read the register by issuing the 0x54 command. In this case, the ADC responds with 0x61, although according to the datasheet it should give 0xE1 to the reset state.

  • Hi Wyrm,

    Bit [7] of the configuration register can change state from 1 to 0 during normal operation, so reading back 0x61 in this case is not a concern.

    If disconnecting the AD4020 from the SPI bus is solving the issue, then I suspect there is some unintentional shorting to ground happening on the MISO line. One potential cause is if more than one device is sharing the SPI bus, and it's MISO line isn't high-impedance while the AD4020 SPI is active. Are there other devices sharing the SPI bus with the AD4020?

  • Hellow!

    There are no more devices on the bus other than the AD4020 and the logic analyzer. Interestingly, when I was looking for a problem, it also helped me to insert a 100-ohm resistor between the ADC and the STM32. I'm not sure at all that MISO in STM32F4 when programming an alternative function is a real HI-Z, in STM32F1 SPI kernel it was configured as AF input floating, STM32F4 have only AF mode in GPIO reg. But there may be leakage currents on my handmade PCB to debug the ADC... Anyway ADC is working, thank you for your support. 

  • Hi Wyrm,

    If putting the 100ohm resistor in series with the AD4020 SDO and the STM32 MISO solved the issue, that does imply there was some contention problem between the two pins. You'd have to look more into the STM32 SPI to debug further, if you choose to.

    Glad things are working now at least!