Post Go back to editing

AD74412R Not Responding to any of the SPI Commands!

Thread Summary

The user encountered issues with the EVAL-AD74412R eval board not responding to commands from an ESP32 over SPI. The solution involved correctly formatting the SPI commands for reading the SILICON_REV register and ensuring the /Reset pin was properly pulled high. The user also noted that the ALERT_STATUS register is cleared by writing 1s, which caused the ALERT pin to go low, and this was resolved by using MODE1 and the correct command sequence.
AI Generated Content
Category: Hardware
Product Number: AD74412R

Hi,

Problem Statement: EV-ad74412R with ESP32 is not Responding to any of the Commands.

Below is the detailed explanation for the same

I am using the Eval board of AD74412R with the default Jumper setting.

1. EV-ad74412R is Powered with the 16V,1A Power Supply - Tested 3.3V and 5V, on the EV Board observed the same voltages.

2. Using the ESP32 with SPI Mode0 Configuration.

3. Both ESP32 and the EV-AD74412R Gnds are connected.

4. SPI Connections are made accordingly.(Also swapped MISO and MOSI connection to rule out any possible connection mistakes)

For Reading the SILICON_REV sending HEX data of 46 00 00 FB

Followed By NOP for reading the Selected Registry 00 00 00 00 

Screen Shoot of the Same

For Reading the SILICON_REV sending HEX data of 2E 00 00 6F

Followed By NOP for reading the Selected Registry 00 00 00 00 

Screen Shoot of the Same

NOP To read the Reselected registry

Experiment Command by selecting Registry and passing the Registry to be read

Same as above NOP are triggered.

Below is my code for the same.

#include <SPI.h>

// Define the Chip Select pin
const int CS_PIN = 5;

uint8_t daq_drv_adc_dac_ad74412r_Crc8(uint8_t *l_pucData, uint8_t l_ucLen)
{
uint8_t l_ucCrc = 0x00;

for (uint8_t l_ucI = 0; l_ucI < l_ucLen; l_ucI++) {
l_ucCrc ^= l_pucData[l_ucI];
for (uint8_t l_ucB = 0; l_ucB < 8; l_ucB++) {
if (l_ucCrc & 0x80)
l_ucCrc = (l_ucCrc << 1) ^ 0x07;
else
l_ucCrc <<= 1;
}
}

return l_ucCrc;
}
void daq_drv_adc_dac_ad74412r_UnAligniedUint16(uint16_t l_uiVal, uint8_t *l_pucBuf)
{
l_pucBuf[1] = l_uiVal & 0xFF;
l_pucBuf[0] = l_uiVal >> 8;
}
static void daq_drv_adc_dac_ad74412r_FormatRegWrite(uint8_t l_ucReg, uint16_t l_uiVal, uint8_t *l_pucBuff)
{
l_pucBuff[0] = l_ucReg;
daq_drv_adc_dac_ad74412r_UnAligniedUint16(l_uiVal, &l_pucBuff[1]);
l_pucBuff[3] = daq_drv_adc_dac_ad74412r_Crc8(l_pucBuff, 3);
//l_pucBuff[3] = 0; //FOR TESTING ALERT PIN FUNCTIONALITY
}

void SpiTxRx(uint8_t *WiteBuff,uint8_t *ReadBuff,uint16_t l_uiLength)
{
uint16_t l_uiTxCount = 0;

while(l_uiTxCount < l_uiLength)
{
ReadBuff[l_uiTxCount] = SPI.transfer(WiteBuff[l_uiTxCount]);

l_uiTxCount ++;
}

}

int ad74412r_reg_write(uint32_t l_ulAddr, uint16_t l_uiVal,unsigned char *ReadBuff)
{
unsigned char WiteBuff[4];

daq_drv_adc_dac_ad74412r_FormatRegWrite(l_ulAddr, l_uiVal, WiteBuff);

digitalWrite(CS_PIN, LOW); // Select device

SpiTxRx(WiteBuff,ReadBuff,4);

digitalWrite(CS_PIN, HIGH); // Deselect device

return 0;
}
#define AD74412R_READ_SELECT 0x41
#define AD74412R_ALERT_STATUS 0x2E
#define AD74412R_SILICON_REV 0x46

void ReadSiliconReg()
{
// to clear the status byte
uint32_t l_ulAddr;
uint16_t l_uiVal;
unsigned char ReadBuff[4];

l_ulAddr = AD74412R_SILICON_REV;
l_uiVal = 0;

ad74412r_reg_write(l_ulAddr,l_uiVal,ReadBuff);
Serial.printf("\n Ad: %X,[0]%02X,[1]%02X,[2]%02X,[3]%02X",l_ulAddr,ReadBuff[0],ReadBuff[1],ReadBuff[02],ReadBuff[03]);

delay(1);

// NOP For reading the Registry
l_ulAddr = 0;
l_uiVal = 0;

ad74412r_reg_write(l_ulAddr,l_uiVal,ReadBuff);
Serial.printf("\n Ad: %X,[0]%02X,[1]%02X,[2]%02X,[3]%02X",l_ulAddr,ReadBuff[0],ReadBuff[1],ReadBuff[02],ReadBuff[03]);

}
void ReadAlertStatusReg()
{
// to clear the status byte
uint32_t l_ulAddr;
uint16_t l_uiVal;
unsigned char ReadBuff[4];

l_ulAddr = AD74412R_ALERT_STATUS;
l_uiVal = 0;

ad74412r_reg_write(l_ulAddr,l_uiVal,ReadBuff);
Serial.printf("\n Ad: %X,[0]%02X,[1]%02X,[2]%02X,[3]%02X",l_ulAddr,ReadBuff[0],ReadBuff[1],ReadBuff[02],ReadBuff[03]);

delay(1);

// NOP For reading the Registry
l_ulAddr = 0;
l_uiVal = 0;

ad74412r_reg_write(l_ulAddr,l_uiVal,ReadBuff);
Serial.printf("\n Ad: %X,[0]%02X,[1]%02X,[2]%02X,[3]%02X",l_ulAddr,ReadBuff[0],ReadBuff[1],ReadBuff[02],ReadBuff[03]);

}
void SelectAndReadAlertStatusRegistryExperimentCommand()
{
uint32_t l_ulAddr;
uint16_t l_uiVal;
unsigned char ReadBuff[4];

l_ulAddr = AD74412R_READ_SELECT;// For reading the
l_uiVal = AD74412R_ALERT_STATUS;//[7:0] READBACK_ADDR Bits[D7:D0] contains the register address to be read.

ad74412r_reg_write(l_ulAddr,l_uiVal,ReadBuff);
Serial.printf("\n Ad: %X,[0]%02X,[1]%02X,[2]%02X,[3]%02X",l_ulAddr,ReadBuff[0],ReadBuff[1],ReadBuff[02],ReadBuff[03]);

delay(1);

// NOP For reading the Registry
l_ulAddr = 0;
l_uiVal = 0;

ad74412r_reg_write(l_ulAddr,l_uiVal,ReadBuff);
Serial.printf("\n Ad: %X,[0]%02X,[1]%02X,[2]%02X,[3]%02X",l_ulAddr,ReadBuff[0],ReadBuff[1],ReadBuff[02],ReadBuff[03]);
}
void setup() {
Serial.begin(115200);

// Set CS pin as output and deselect device
pinMode(CS_PIN, OUTPUT);
digitalWrite(CS_PIN, HIGH);

// Initialize SPI
SPI.begin();
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0)); // 1 MHz, MSB first, Mode 0


delay(100);
Serial.println("SPI initialized at 1 MHz");
}

void loop() {

ReadSiliconReg();
delay(1);
ReadAlertStatusReg();
delay(1);
SelectAndReadAlertStatusRegistryExperimentCommand();
delay(1);

delay(1000);

}

Parents Reply Children
No Data