issue in HSDC connection between ADE7880 and STM32F407

Hi all,

i am working on waveform sampling mode of ADE7880 .I have established i2c connection and done code for HSDC enabling and configuring, 

But the issue is in for collecting HSDC data i have enabled  SPI port in STM, But its not communicating properly

MY code for SPI is 

    static void MX_SPI1_Init(void)
{

  /* SPI1 parameter configuration*/
  hspi1.Instance = SPI1;
  hspi1.Init.Mode = SPI_MODE_SLAVE;
  hspi1.Init.Direction = SPI_DIRECTION_2LINES;
  hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
  hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
  hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
  hspi1.Init.NSS = SPI_NSS_SOFT;
  hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
  hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
  hspi1.Init.CRCPolynomial = 10;
  if (HAL_SPI_Init(&hspi1) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN SPI1_Init 2 */

  /* USER CODE END SPI1_Init 2 */

}

and in main
uint8_t tx_data[2];
uint8_t rx_data[2];

tx_data[0] = 0xE5; //addr | 0x80; // read operation
tx_data[1] = 0x0C; // dummy byte for response

hal_status = HAL_SPI_TransmitReceive(&hspi1, tx_data, rx_data, 2, 1000);

it return error
Where is the problem how to correct it.

help plz

Thanks in Regards,

  • Can you provide scope captures of your hsdc signals?

    I am not sure how your test code is supposed to work.  Are you doing a loop back sending data out and reading back? Your spi is in slave mode, so I don't think you will get a chip select in this mode. If this is the case if you set spi to master is should loop back correctly. 

    Dave