-
1. Re: SPIS_GetRxBufferSize()
LinglingG_46Jun 12, 2019 6:48 PM (in response to DaCh_4286001)
Hi Simon,
If the Rx_buffersize is 0 when you read SPIS_GetRxBufferSize(), I think it is possible that you have cleared your Rx buffer in your code.
Could you show us the function: SPIM_ReadTxStatus() ?
Suggestions:
You can design the logic of the program like this:
/* Start transfer */
SPIM_SpiUartPutArray(dummyBuffer, PACKET_SIZE);/* Wait for the end of the transfer. The number of transmitted data
* elements has to be equal to the number of received data elements. */
while (PACKET_SIZE != SPIM_SpiUartGetRxBufferSize());/* Clear dummy bytes from TX buffer */
SPIM_SpiUartClearTxBuffer(); -
-
3. Re: SPIS_GetRxBufferSize()
DaCh_4286001 Jun 13, 2019 6:04 AM (in response to LinglingG_46)Hi LinglingG,
I don't think I clear the Rx buffer in my code. I just initialize all variables above the code I show in question.
I also tried the suggestion you give me but it looks like the biffer size counts from 4, then 8, then 9 and stops counting.
-
-
5. Re: SPIS_GetRxBufferSize()
NoriakiT_91 Jun 15, 2019 5:49 AM (in response to DaCh_4286001)1 of 1 people found this helpfulI can reproduce the phenomenon on my PSoC 5LP board by modifying the SPI_Design project example.
It seems that the following context does not work as you expected.
while ((SPIM_ReadTxStatus() & SPIM_STS_TX_FIFO_EMPTY) != SPIM_STS_TX_FIFO_EMPTY );
In the SPI Master component datasheet, it was described as follows.
Tx FIFO Empty: Set when the Tx Data FIFO is empty (does not indicate the Tx buffer RAM array conditions). This means that this bit does not indicate the status of the software FIFO on the RAM area. It just indicates the status of the hardware FIFO contained in UDBs. So, no data bytes are sent to slave and the GetRxBufferSize() returns ZERO.
If you want to detect "the transmit from master is completed" as you write in the comment, SPIM_STS_SPI_DONE bit should be used.
while ((SPIM_ReadTxStatus() & SPIM_STS_SPI_DONE) != SPIM_STS_SPI_DONE);
The GetRxBufferSize() returns 7 not 10. This is because the size of software buffer is set to 8 in the project example.
If the software buffer sizes are increased to 16 for all combinations of SPIM/SPIS and RX/TX, the GetRxBufferSize() returns 10 meaning 10 elements are stored in the software FIFO.
Please refer attached project.
Regards,
Noriaki
-
6. Re: SPIS_GetRxBufferSize()
DaCh_4286001 Jun 15, 2019 6:12 AM (in response to NoriakiT_91)Thank NoriakiT
Why no data bytes are sent to slave and the GetRxBufferSize() returns ZERO? in my mind After SPIM Tx FIFO, data will go into SPIS Rx FIFO. So if SPIM Tx FIFO is empty then the data are all transferred
Simon
-
7. Re: SPIS_GetRxBufferSize()
NoriakiT_91 Jun 15, 2019 6:37 AM (in response to DaCh_4286001)1 of 1 people found this helpfulSimon,
Maybe you see following description in the component datasheet.
It just says "Tx FIFO empty" and also says "for more information, see Status Register Bits."
In the "Status Register Bits" section I found a strange description regarding the Tx FIFO Empty.
I suppose that "no data bytes are sent to slave" because the SPI clock frequency is very low and the CPU is going to write data bytes too quickly.
Regards,
Noriaki
-
8. Re: SPIS_GetRxBufferSize()
MoTa_728816 Jun 16, 2019 3:54 AM (in response to DaCh_4286001)Hi,
Since this topic seemed to be very interesting,
I downloaded Noriaki-san's sample and tried with my CY8CKIT-059.
As I don't have LCD I added following lines to see the result.
Meantime, I suspected that as you were not using Rx_buffersize anywhere in the source code.
I used it to call my dump_data() function, so that it will not be optimized out by the compiler.
When I hit the assignment line of Rx_buffersize, naturally Rx_buffersize was 0,
as it was not assigned.
But when I stepped over the line, at the next statement,
Rx_buffersize was still ZERO.
Then finally when I hit the line where I called my dump_data() with Rx_buffersize as an argument.
The Rx_buffersize has value of 0x0000000A!
And in my TeraTerm the log was shown
So I believe that Rx_buffersize was actually assigned,
but somehow until it will be used, the debugger reported the value as ZERO.
moto
-
9. Re: SPIS_GetRxBufferSize()
DaCh_4286001 Jun 16, 2019 7:14 AM (in response to MoTa_728816)Thank you Motto,
In my other article related to this. Bob suggests that I should never use delay or wait in ISR function. I tried that and now it is working.
Simon
-
10. Re: SPIS_GetRxBufferSize()
DaCh_4286001 Jun 16, 2019 7:15 AM (in response to NoriakiT_91)Thank you Noriaki,
In my other article related to this. Bob suggests that I should never use delay or wait in ISR function. I tried that and now it is working.
Simon