AD7124-4 SPI read problem

Hello,

I''m trying to read the device ID at 0x05 on the AD7124-4 using an stm32f4 discover board. Here are my initialization and read routines. 

//initialization

SPI_InitStruct.SPI_BaudRatePrescaler=SPI_BaudRatePrescaler_256; // This would come to 45/256 Mhz
SPI_InitStruct.SPI_Direction=SPI_Direction_2Lines_FullDuplex;
SPI_InitStruct.SPI_Mode=SPI_Mode_Master;
SPI_InitStruct.SPI_DataSize=SPI_DataSize_8b;
SPI_InitStruct.SPI_FirstBit=SPI_FirstBit_MSB;
SPI_InitStruct.SPI_CPOL=SPI_CPOL_Low; //Clock polarity
SPI_InitStruct.SPI_CPHA=SPI_CPHA_2Edge; //Clock phase
SPI_InitStruct.SPI_NSS=SPI_NSS_Soft;

//read

uint8_t SPI_Rx(uint8_t adress)
{
   GPIO_ResetBits(GPIOE,GPIO_Pin_4); // This is the chip select
   adress=0x40|adress; // creating the command byte


   while(!SPI_I2S_GetFlagStatus(SPI2,SPI_I2S_FLAG_TXE));
   SPI_I2S_SendData(SPI2,adress);


   while(!SPI_I2S_GetFlagStatus(SPI2,SPI_I2S_FLAG_RXNE));
   SPI_I2S_ReceiveData(SPI2);


   while(!SPI_I2S_GetFlagStatus(SPI2,SPI_I2S_FLAG_TXE));
   SPI_I2S_SendData(SPI2,0x00); //dummy byte


   while(!SPI_I2S_GetFlagStatus(SPI2,SPI_I2S_FLAG_RXNE));

   GPIO_SetBits(GPIOE,GPIO_Pin_4);
   return SPI_I2S_ReceiveData(SPI2);
}

Here's what my logic analyzer was reading. Data is MOSI and DIO15 is MISO:

  • 0
    •  Analog Employees 
    on Nov 12, 2017 8:23 PM over 3 years ago

    Hi, Jay.

    May I know what is your controller digital supply? It is recommended to remove the 0 ohm resistor just to ensure that no other connections are made on your digital interface. If it is not connected anywhere in the circuit it would be fine. Usually when DRDY stops pulsing at any time and it stays high or low this indicates that the serial interface has become asynchronous (incorrect number of SCLK pulses, glitches on the SCLK line) like mentioned above. Do you have SDP-B board with you? Can you try to use the board with SDP board and check if you are seeing the same issue?

    Thanks,

    Jellenie

  • 0
    •  Analog Employees 
    on Aug 2, 2018 3:58 PM over 2 years ago
    This question has been assumed as answered either offline via email or with a multi-part answer. This question has now been closed out. If you have an inquiry related to this topic please post a new question in the applicable product forum.

    Thank you,
    EZ Admin