AD74412R
Recommended for New Designs
The AD74412R is a quad-channel software configurable input/output solution for building and process control applications. The AD74412R contains functionality...
AD74412R on Analog.com
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);
}
.
Hi,
I have made another observation Since Reset pin is supposed to be connected to the Microcontroller, which was not connected with pull up, later JP12 is connected and the 10k pullup with 3.3V is done, up on pressing S1 Reset button device Reset pin goes low...After doing this also device is not responding.
However RESET_SHLD externally connected with the Pull up resistor, with JP12 & JP13 being connected to operate Reset functionality.
Hi,
I have made another observation Since Reset pin is supposed to be connected to the Microcontroller, which was not connected with pull up, later JP12 is connected and the 10k pullup with 3.3V is done, up on pressing S1 Reset button device Reset pin goes low...After doing this also device is not responding.
However RESET_SHLD externally connected with the Pull up resistor, with JP12 & JP13 being connected to operate Reset functionality.
Added New Command to Clear the ALERT_STATUS by writing 2E 00 01 68 FOLLOWED by 00 00 00 00 to Clear the Previous triggered command/to read the status.
Also tried with 2E FF FF 4B, even though device not responding to the command and the ALERT Status pin not becoming High.
Any suggestion/solution is greatly appreciated.
Thank you in advance.
Breakthrough in making it work! I made MODE1 and Read Status Registry by passing 2E FF FF 4B, Alert pin is going high now but Trying to read the SILICON_REV but device not responding always getting 0xff only.
Hi Bharadwaj ,
I am happy you are making progress on the same.
Concerning the Reset, good job finding out the same, this is most common oversight when using external micro.
Please ensure, that /Reset pin will stay high during the entire operation. (Defined by voltage level or external pull up.)
Based on your description it seems to me, that RESET was already taken care of correctly.
Let's focus on other challenges you are facing.
Regards,
Arnost
Hi Bharadwaj ,
please note for the WRITE operation only single SPI frame is needed on the SDI pin. Even when previously read was requested, output data will be send on SDO pin, while write is happening.
By Passing 2E FF FF 4B on SDI, will cause clearing of the ALERT_STATUS (As bits are cleared by writing "1" in this case, for "added layer" of protection) - this causing as you correctly observe ALERT pin to go low. Note: Other registers are cleared by writing 0 and set by writing 1 to corresponding bitfields only Alerts are expections.
Read of the SILICON_REV should be as follows send (hex) 41 00 46 38 on SDI and then followed by 00 00 00 00 on SDI (simultaneously reading output data on SDO).
Regards,
Arnost
Hi APavlik,
Thank you very much for sharing the details. Everything finally fell into place! I sent the command as you suggested, and it worked perfectly.
I truly appreciate your time, effort, and the support you provided — it made a real difference.
Thanks again...