Hello !
I've been reading how SPI works and did some example
First of all in tx_buff[0] I add one bit which is shifted to the left << 7. I know it is a Write bit, and I read from this address the data which is received in HAL_SPI_Receive.
The thing is why I don't use the Read bit anywhere but I use only Write bit?
Second thing is why in HAL_SPI_Receive why I don't send the address again with the Read bit ?
It's weird at most.
Second question was about dummy data. Which I don't understand. If the first byte is to send the address of the device then the second byte which is 0x00 a dummy data doesn't overwrite the register I was pointing to in the first byte ?
Is it also present in my code ?
I've read about dummy data while trying to find answer about this Read bit.
I've been reading how SPI works and did some example
C:
uint8_t spi_tx_buff[10], spi_rx_buff[10];
spi_tx_buff[0] = (0x01 << 7) | 0x0F;
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspi1, spi_tx_buff, 1, 50);
HAL_SPI_Receive(&hspi1, spi_rx_buff, 1, 50);
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, GPIO_PIN_SET);
printf("Expected 11010100 (212 in decimal) : %d\n ", spi_rx_buff[0]);
The thing is why I don't use the Read bit anywhere but I use only Write bit?
Second thing is why in HAL_SPI_Receive why I don't send the address again with the Read bit ?
It's weird at most.
Second question was about dummy data. Which I don't understand. If the first byte is to send the address of the device then the second byte which is 0x00 a dummy data doesn't overwrite the register I was pointing to in the first byte ?
Is it also present in my code ?
I've read about dummy data while trying to find answer about this Read bit.




