Post Go back to editing

No reply from AD74412R

Category: Software
Product Number: AD74412R

I am trying to establish SPI communications to a Mikrow AD-SWIO board containing an AD7412R. This board is recommended by AD as a third-party solution on the AD74412R device page.

I am unable to get it to respond to my SPI commands. I am attempting to follow the read back mode procedure in the data sheet and while I think I am issuing the right commands, the device will still not reply to me.  

Here is an image from my logic analyzer:  


I have shown the RST, CS, ALERT, MOSI, MISO, and CLK pins on the logic analyzer. All of them except the MISO are at 0V at logic 0 and around 3.3V at logic 1 as confirmed voltages with an oscilloscope. The MISO pin appears to always be in the high impedance state, but I do not know why. 

I am controlling the RESET pin as shown on one of the traces on my logic analyzer. It is not floating. You can see I am bring the RESET pin low and then raising it back up at the start of the read procedure. I have also tried leaving the RESET pin high at all times but it has not helped. I am also controlling the CS pin. You can see my code which I also attached.

I am using an STM32L476RG as the SPI master.  

Here is my SPI initialization code and the code I use to read and write registers:    

static void MX_SPI2_Init(void)

  /* USER CODE BEGIN SPI2_Init 0 */

  /* USER CODE END SPI2_Init 0 */

  /* USER CODE BEGIN SPI2_Init 1 */

  /* USER CODE END SPI2_Init 1 */
  /* SPI2 parameter configuration*/
  hspi2.Instance = SPI2;
  hspi2.Init.Mode = SPI_MODE_MASTER;
  hspi2.Init.Direction = SPI_DIRECTION_2LINES;
  hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
  hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
  hspi2.Init.CLKPhase = SPI_PHASE_2EDGE;
  hspi2.Init.NSS = SPI_NSS_SOFT;
  hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256;
  hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
  hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
  hspi2.Init.CRCPolynomial = 7;
  if (HAL_SPI_Init(&hspi2) != HAL_OK)
  /* USER CODE BEGIN SPI2_Init 2 */

  /* USER CODE END SPI2_Init 2 */


HAL_StatusTypeDef ReadRegister(uint8_t addr, uint8_t *byte)
	HAL_StatusTypeDef hal_status;
	uint8_t tx_data[4] = {0};
	uint8_t rx_data[4] = {0};

	volatile uint8_t readback_addr = 0;
	volatile uint8_t data_h = 0;
	volatile uint8_t data_l = 0;
	volatile uint8_t crc = 0;

	//	adswio_reset();
//	delay_us(100);

	// raise and lower CS
//	delay_us(2);

	tx_data[0] = 0x41;  	// address of READ_SELECT register
	tx_data[1] = 0x0;
	tx_data[2] = addr;
	tx_data[3] = adswio_cal_crc8(tx_data,3);

	hal_status = HAL_SPI_Transmit(&hspi2, tx_data, 4, 500);
	hal_status = HAL_SPI_Receive(&hspi2, rx_data, 4, 500);

//	if (hal_status == HAL_OK) {
//		tx_data[0] = 0x0;  		// address of NOP register
//		tx_data[1] = 0x0;		// AUTO_RD_EN and SPI_RD_RET_INFO bits set to 0
//		tx_data[2] = 0x0;		// address of register to read, the SILICON_REV register
//		tx_data[3] = adswio_cal_crc8(0,0);
////		hal_status = HAL_SPI_TransmitReceive(&hspi2, tx_data, rx_data, 4, 1000);
//	}

	if (hal_status == HAL_OK)
		readback_addr = rx_data[0];
		data_h = rx_data[1];
		data_l = rx_data[2];
		crc = rx_data[3];
	return hal_status;

I appreciate your help! I've been working on this for several days trying to find a signal that is incorrect, but so far I can't determine why it is not talking to me. I have also swapped both the MCU and the AD-SWIO board. This has not helped. All boards perform equally bad. 

I must be doing something wrong with the RESET or CS pins? Or is there something wrong with my SPI initialization code or the code I am using to attempt to read a register? Please look at my code snippets and at the image from my logic analyzer. Maybe you can see something I have missed.

Thank you for your help!


  • Hi Clark,

    please contact MikroE for this querry and concerning further support of this board, I am not able to provide you relevant support for this, as Mikrow AD-SWIO board is third party solution.

    However I can give advice, concerning the signals I see: What makes me suspicious on your plots is RST signal, if that's reset pin, it cause reset after each write to AD74412R. Result of this is, that AD74412R cannot answer, because is read is two stage process. (see AD74412R datasheet

    Please hold RST signal high "all the time", this should result in answer at second write. Be sure to allow 1ms for the part to come out of reset, once the signal toggle high.

    Best regards,


  • Arnost

    Well I am certainly disappointed to hear you will not support me further since I purchased the board from Mikroe. You know, I have compared the schematics of the two boards and there is very little difference between the Mikroe board and your eval board. As far as I can tell, the Arduino pins of the EVAL board are connected to the AD74413R in the same manner the pins on the Mikroe board connect to the AD74412R. So I don't understand why I can't get support because I am using a Mikroe still uses an AD74412R and it seems to be using it in an almost identical manner as used in the EVAL board.

    Anyway, I need to get to the bottom of this problem. I am developing a small SCADA system with a cellular radio and I really want to upgrade from the analog IO I am using to your AD74412R. I see too many advantages with the AD74412R to abandon it at this point. So today I ordered from Mouser the EV-AD74413RSDZ EVAL board and also the EVAL-SDP-CS1Z computer interface.

    I will use the computer interface only to help me more quickly understand the operation of the board. Then I will remove the computer interface and connect my MCU to the EVAL board.

    I will connect my STM32L476RG MCU to the Arduino connections on the EVAL board just as I have connected it to the Mikroe board. That should quickly tell me whether the problems are caused by my software or by defective Mikroe boards.

    Regarding the RESET pin, as I mentioned above in my original post, I have also tried leaving the RESET pin high. Today I also added a 10ms delay at startup. Nothing works. I understand why you think there must be a problem with the RESET pin, but I have carefully looked at the RESET pin with my storage oscilloscope and with a logic analyzer and as far as I can tell, every one of my tests has made the RESET pin high before starting the two stage register read process. 

    At this point it seems that either all the Mikroe boards I have purchased are defective or that the problems may be caused by my SPI initialization code or the code I am using to perform the two stage register read process. I have asked if someone would quickly review my code in case I have misunderstood the data sheet, but so far that has not been done.  Will someone at AD take a quick look at my code if I continue to have problems interfacing my STM32 MCU with the EVAL board? I hope so. I really want this to work.

  • Hi Clark,

    I understand your disappointment. Of course, we will support your AD74412R queries as much as possible (but I am not familiar with the MikroE H/W & S/W solutions).

    Concerning the HW, I suggest checking the board voltages of AD74412R.

    AVDD = 6V to 28.8V; DVCC = 3.3V – as you are using 3V3 logic (datasheet range is DVCC = 2.7V to 5.5V); AVCC = 4.5V to 5.5V; ALDO1V8 = 1.8V;  DLDO1V8 = 1.8V; ALDO5V = 5V; AVSS = -DVCC; To be sure, all is powered up correctly.

    Concerning the SW, I have checked your snippet of code and can see nothing wrong. (Besides, as I have mentioned already, reset is not required and should be removed from occurring before every write/read sequence.)

    Your written data looks to be ok, - 0x41, 0x00+0x2E (Alert Status register), 0x27 CRC.  

    Would it be possible to generate another set of plots with reset held high?

    Also, please provide little zoomed results so I can check the signal timing.


    Best Regards,


  • Hi Clark,

    one more thing spotted on your plots. CS signal needs to go back to high between every transaction (32 bit write). I have missed this in your code before.

    Let me know, if you will be able to find the issue.

    Best regards,


  • Arnost


    Bringing SYNC high for a brief period between each 32 bit transaction fixed it. Great news! I'm now getting correct data.

    Controlling SYNC like this seems a little counter-intuitive. So I searched the data sheet to see how I missed this requirement while perform a two part read. I sort of found what I missed on Figure 52.

    That Figure shows SYNC transitioning faster than SCLK. and SCLK is also toggling too slow. Those things made no sense so I guess I ignored it. But suddenly I discovered Figure 42 makes perfect sense if SYNC is really SCLK and SCLK is really SYNC. You might want to have the documentation people fix that error. I further understand that SYNC has more purposes than simply enabling the chip for SPI comms. It is also a fundamental part of acquiring data from the AD7441X devices. I think it wuld be very helpful for us newbys to fix Figure 52 an also explain in more detaail why SYNC does works the way it does and how it is different than a traditional CS.

    Anyway, IT IS WORKING. That eliminates a big worry here. Thank you again! Now on to improving my product with wonderful device from AD!

    With high regards,


  • Hi Clark,

    I am happy it works for you.

    Thank you for reply and your suggestions concerning the documentation. Your inputs are noted. 



Reply Children
No Data