SPI communication with LAN9252 only works the first time
Hi everyone. I am trying to communicate with a board called EVB-LAN9252-SPI via SPI, and I am only getting the datasheet-correct result for the first SPI request.
If I send 0x03 and then 0x0050, I should get 0x92520001. Right now, I only get 0x92520001 for the first reception, and after that, I get 0x00480000, 0x00440000, and 0x00400000, which is the same value as 0x00400000. What is wrong with my setup?
The code is as follows.
void spi_wirte(void)
{
uint8_t tx[3]={0x03, 0x00, 0x50};
uint8_t rx[4]={0,};
while(1)
{
HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspi1, tx,3,100);
HAL_SPI_Receive(&hspi1, rx,4,100);
HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_SET);
printf("data :");
for (int i=0;i<4;i++)
printf("%02X",rx[i]);
printf("\n");
HAL_Delay(10);
}
}
Thank you.
