RT105x: how to count received byets on a slave SPI without using DMA and/or interrupts

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

RT105x: how to count received byets on a slave SPI without using DMA and/or interrupts

497 次查看
mastupristi
Senior Contributor I

In my board I have an FPGA master from SPI, and the RT1051 is the slave

"Normal" SPI transactions are 279 bytes long, so I programmed the DMA to trigger an interrupt every 279 bytes.

For various causes it may happen that the FPGA may abort the transaction before 279 bytes. RT1051 should notice "aborted/partial" transactions.

I was thinking of using the "Frame Complete Flag" interrupt, which should trigger an interrupt when the PCS is deasserted.

But how can I tell the difference between a competed transaction and an aborted one after it has jumped into the interrupt handler? I would need to know the "true" number of bytes that the SPI received in the last transaction.

Then how do I get/calculate this number? I can't trust the DMA that it might not have transferred the last received SPI byte yet (it might be busy on another channel, or it might be bus busy). I can't use interrupts since there would be too many of them and the risk of losing some bytes by miscounting them is high. It would also be too onerous in terms of processing.

I can't use "Word Output Trigger," which would be perfect via XBAR and a timer counter, but unfortunately on RT105x this trigger is not connected to XBAR (nor any other)

Do you have any other ideas for obtaining/calculating the number of bytes received on SPI?

Or maybe you have a different idea to distinguish a completed transaction from an aborted one?

 

best regards

Max

标签 (1)
标记 (1)
0 项奖励
回复
1 回复

455 次查看
mastupristi
Senior Contributor I

Perhaps instead of the "Frame Complete Flag" I should use the "Transfer Complete Flag" (triggered when the PCS is deasserted and the FIFO is empty). This should give me a guarantee that the DMA has transferred up to the last byte, right?
At that point I can use TCD to decide if the transaction is complete (279 bytes long) or incomplete.
What do you think?

0 项奖励
回复