- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using the SPI bus of Aurix MCU TC397 to drive the audio decoding chip vs1053, and refer to the demo"SPI_ CPU_ 1_ KIT_ TC397_ TFT"。 This DEMO demonstrates how to use QSPI2 as the master and QSPI3 as the slave and send data from the master to the slave. These also works well in my project.
But how can I make the master read data from the slave? I tried to modify "g_Qspi.spiBuffers.spiSlaveTxBuffer" and "g_Qspi.spiBuffers.spiSlaveRxBuffer", but The correct data is still cannot be read from "g_Qspi.spiMasterTxBuffer" or "g_qspi.spiMasterRxBuffer" (I can only read 0x01 of the data sent before from the former, and 0x00 from the latter). And this phenomenon is different from what I observed on the oscilloscope.
The blue line in the figure is MOSI, the green line is MISO, and the yellow line is CLK.
It can be seen that the data of MISO seems to be 0xff, which is not only has nothing to do with my settings in "g_Qspi.spiBuffers.spiSlaveTxBuffer". And also is irrelevant with The 0x00 read from "g_qspi.spiMasterRxBuffer" . This is what troubles me. It makes my master(TC397) unable to determine the status of the slave(vs1053).
Solved! Go to Solution.
- Labels:
-
Aurix
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes, i generated my code based on the code above. However when i use the origin code, the master don't receive anything. So l write a function instead.like this:
/* This function starts the data transfer(1Byte) */
void SPI_transferByteData(uint8 *data)
{
while (IfxQspi_SpiSlave_getStatus(&g_qspi.spiSlave) == SpiIf_Status_busy ||
IfxQspi_SpiMaster_getStatus(&g_qspi.spiMasterChannel) == SpiIf_Status_busy)
{ /* Wait until the previous communication has finished, if any */
}
/* Send a data stream(Txbuffer) through the SPI Master and read slave into Rxbuffer*/
memcpy(&g_qspi.spiBuffers.spiMasterTxBuffer[0], data, SPI_BUFFER_SIZE);
IfxQspi_SpiMaster_exchange(&g_qspi.spiMasterChannel, &g_qspi.spiBuffers.spiMasterTxBuffer[0], &g_qspi.spiBuffers.spiMasterRxBuffer[0], SPI_BUFFER_SIZE);
memcpy(data, &g_qspi.spiBuffers.spiMasterRxBuffer[0], SPI_BUFFER_SIZE);
}
now it can send 1 byte while receive 1 byte .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
void transferData(void)
{
while(IfxQspi_SpiSlave_getStatus(&g_qspi.spiSlave) == SpiIf_Status_busy ||
IfxQspi_SpiMaster_getStatus(&g_qspi.spiMasterChannel) == SpiIf_Status_busy)
{ /* Wait until the previous communication has finished, if any */
}
/* Instruct the SPI Slave to receive a data stream of defined length */
IfxQspi_SpiSlave_exchange(&g_qspi.spiSlave, NULL_PTR, &g_qspi.spiBuffers.spiSlaveRxBuffer[0], SPI_BUFFER_SIZE);
/* Send a data stream through the SPI Master */
IfxQspi_SpiMaster_exchange(&g_qspi.spiMasterChannel, &g_qspi.spiBuffers.spiMasterTxBuffer[0], NULL_PTR, SPI_BUFFER_SIZE);
verifyData();
}
Have you modified above code? pdf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes, i generated my code based on the code above. However when i use the origin code, the master don't receive anything. So l write a function instead.like this:
/* This function starts the data transfer(1Byte) */
void SPI_transferByteData(uint8 *data)
{
while (IfxQspi_SpiSlave_getStatus(&g_qspi.spiSlave) == SpiIf_Status_busy ||
IfxQspi_SpiMaster_getStatus(&g_qspi.spiMasterChannel) == SpiIf_Status_busy)
{ /* Wait until the previous communication has finished, if any */
}
/* Send a data stream(Txbuffer) through the SPI Master and read slave into Rxbuffer*/
memcpy(&g_qspi.spiBuffers.spiMasterTxBuffer[0], data, SPI_BUFFER_SIZE);
IfxQspi_SpiMaster_exchange(&g_qspi.spiMasterChannel, &g_qspi.spiBuffers.spiMasterTxBuffer[0], &g_qspi.spiBuffers.spiMasterRxBuffer[0], SPI_BUFFER_SIZE);
memcpy(data, &g_qspi.spiBuffers.spiMasterRxBuffer[0], SPI_BUFFER_SIZE);
}
now it can send 1 byte while receive 1 byte .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here list the original and modified for reference.