Post Go back to editing

No reply from AD74412R

 I am trying to establish SPI communications to a Mikrow AD-SWIO board containing an AD7412R. 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 around 0V at logic 0 and around 3.3V at logic 1. I am sure the pins are not floating. THE MISO pin appears to be in the high impedance state, but I do not know why. 

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.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
  hspi2.Init.CRCPolynomial = 7;
  hspi2.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
  hspi2.Init.NSSPMode = SPI_NSS_PULSE_DISABLE;
  if (HAL_SPI_Init(&hspi2) != HAL_OK)
  {
    Error_Handler();
  }
  /* 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();
	HAL_GPIO_WritePin(RST_ADSWIO_2_GPIO_Port, RST_ADSWIO_2_Pin, RESET);
	delay_us(100);
	HAL_GPIO_WritePin(RST_ADSWIO_2_GPIO_Port, RST_ADSWIO_2_Pin, SET);

	// raise and lower CS
	HAL_GPIO_WritePin(CS_ADSWIO_2_GPIO_Port, CS_ADSWIO_2_Pin, SET);
	delay_us(2);
	HAL_GPIO_WritePin(CS_ADSWIO_2_GPIO_Port, CS_ADSWIO_2_Pin, RESET);


	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, 1000);

	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);
		hal_status = HAL_SPI_Receive(&hspi2, 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.



Added last sentence.
[edited by: ClarkS at 11:13 PM (GMT -4) on 26 Jun 2022]