SPI Data Register is Always 0 on my STM32F302CBTx I have a code working on STM32L476VETx, it reads SPI data from AFE4400 Chip. Now I want to use this code on STM32F302CBTx (SPI2) but it does not work since I always get zero on data register.
Here is the code:
uint32_t AFE4490Read (uint8_t address){
uint32_t data = 0;
uint8_t buf[3];
HAL_GPIO_WritePin(AFE_STE_GPIO_Port, AFE_STE_Pin, LOW); // enable device
HAL_SPI_Transmit(&hspi2, &address, 1, 1000); // send address to device
HAL_SPI_Receive(&hspi2, buf, 3, 1000); // SPI.transfer (data);
data |= (((uint32_t)buf[0])<<16); // read top 8 bits data
data |= (((uint32_t)buf[1])<<8); // read middle 8 bits data
data |= ((uint32_t)buf[2]); // read bottom 8 bits data
HAL_GPIO_WritePin(AFE_STE_GPIO_Port, AFE_STE_Pin, HIGH); // disable device
return data; // return with 24 bits of read data
}