Clarifications regarding SPI transmission
I was working on a MP3 DECODER called VS1003. during reading the registers either i can send and receive data at SPI bus separately like
uint16_t result;
uint8_t temp = 0;
vs1003_control_mode_on();
delayMicroseconds(1); // tXCSS
HAL_SPI_Transmit(&hspi2, &VS_READ_COMMAND, 1, HAL_MAX_DELAY); //command for read
HAL_SPI_Transmit(&hspi2, &_reg, 1, HAL_MAX_DELAY); //register
//READ DATA
HAL_SPI_Receive(&hspi2, &temp, 1, HAL_MAX_DELAY);
result = temp << 8;
temp = 0;
HAL_SPI_Receive(&hspi2, &temp, 1, HAL_MAX_DELAY);
result |= temp;
or i can do it using the function transmitReceive like
uint16_t result;
uint8_t temp = 0;
vs1003_control_mode_on();
delayMicroseconds(1); // tXCSS
uint8_t tx_data[] = { VS_READ_COMMAND, _reg };
uint8_t rx_data[2] = { 0, 0 };
HAL_SPI_TransmitReceive(&hspi2, tx_data, rx_data, 2, HAL_MAX_DELAY);
result = (rx_data[0] << | rx_data[1];
ISSUE i am facing is while transmitting the data using separate transmit and receive function it is working fine, but while using transmitrReceive function, i am unable to read any data.
Any suggestion would be highly appreceiable.
