2018-11-10 07:49 PM
I have declared the following variable:
uint16_t SPIRx;
If I use this line to read SPI data, the compiler doesn't throw warnings:
HAL_SPI_Receive(&hspi1, (uint8_t *)&SPIRx, 2, 500);
But if I say:
HAL_SPI_Receive(&hspi1, (uint16_t *)&SPIRx, 1, 500);
It throws a warning because the pointer should be 8 bit.
What is the right way to use the SPI Receive module to read a 16 bit word?
2018-11-10 09:50 PM
The pointer needs to be cast as 8-bit either way, but the count depends on the width you have told the SPI peripheral to use.