stm32 SPI Reading from AD7091R

Hello friends,
We used the CN-0336 reference design for our analog input module design. There is AD7091R 12-bit ADC on this design. I searched the documents of the relevant design and tried to read the design that we made specifically for the time diagrams in the given contents, on the STM32 f030 nucleo board, but I could not succeed. I would like to ask those who can provide information and help on this matter to get back to me. My variables are 

uint8_t spi_buf[2]={0,0};
uint16_t adc_value;
uint8_t i;
float volt=0;
float testdata[60];


code and design specs here ;

  • Hello,

    It seems that in the 336 example the SPI is set to 4MHz clock speed, as evidenced in the comment here, and polarity is low and phase is leading edge. It seems that your configurations should work, going by the first picture, even if the clock speed is lower. Looking at Table 2, page 5 of the datasheet, it seems that the part supports a maximum of 50MHz on its SPI communication. So you are within range.

    Does this answer your query?

    Regards,
    Andrei

  • Hello,

    Can you do some measurements and see if the transfer waveforms are respecting the timings specified at page 5 in the datasheet?

    From what i see you got no delays between the gpio writepin functions and the adc needs at least 50ns between the last SCLK and the next CONVST pulse.

    Sergiu

  • Thanks a lot guys for your feedback.( , )
    After trying many different cards, I realized that the cards were defective or that I had broken the cards over time. However, one of them gives output with the code and the settings in the image I shared. The results I got are roughly as follows:
    4ma input current = 16 decimal
    5ma input current = 207 decimal
    6ma input current = 430 decimal
    7ma input current = 680 decimal
    8ma input current = 900 decimal
    9ma input current = 1130 decimal
    10ma input current = 1360 decimal
    11ma input current= 1615 decimal
    12ma input current= 1855 decimal
    13ma input current= 2070 decimal
    14ma input current= 2300 decimal
    15ma input current=2560 decimal
    16ma input current = 2780 decimal
    17ma input current = 3000 decimal
    18ma input current= 3250 decimal
    19ma input current = 3500 decimal
    20ma input current = 3775 decimal (on 3.10 V )

    I have some questions on this subject, thank you in advance for your valuable time and help;

    1.) Why do my outputs between 4-20 mA with 12 bit resolution do not output exactly at the desired resolution, what could be the reason?

    2.) How can I create an ns-level delay for the STM32 f030-nucleo board? timer or an alternative way?

    3.)How stable does my design look based on voltage-current inputs?
    4.) Finally, how likely is it that I will actually damage other cards? In other words, could I have had problems with the other cards I tried, the possibility of disrupt or the design?

  • Hello,

    1) How stable is the input you give to the adc? For example  the last measurement 3775(raw) * 3300(reference) / 4096(lsb) ~= 3041 (close to your 3100 mV)

    2) Using a timer would be a more accurate solution

    3) This depends on the application it's used for.

    4) There is a requirements table for the supply in the eval board guide

  • Thank you so much end of the project ı will share conclusions.