Content originally posted in LPCWare by capiman on Sun Mar 15 01:00:39 MST 2015
Hi Mike,
many thanks for your reply. I just want to show the following example:
Take the case the packet shall be (always) 8 bytes long.
(fixed length or length in first byte or so)
Case 1: CS low, 8 bytes transmitted, CS high.
Case 2: CS low, 4 bytes transmitted, CS high, "some" time later, CS low, 4 remaining bytes transmitted, CS high.
First case is valid, second case is invalid, because I get 2 packets which are too short.
For case 2:
Ok, I refuse the first one (first 4 bytes) as too short, but then I get the second one and try again to decode it with random outcome, because it is the second part of a packet. Instead of the length I get user data. Ok, normally you have some kind of checksum, so you just discard both too small packets.
Regarding the pin interrupt:
Yes I already considered this, but had hoped there is a way just with the SSP peripheral to tell me this kind of info.
With pin interrupt, there is (perhaps) the following problem:
Take the case I configured the pin interrupt triggering by rising edge on CS.
So I receive the data via SSP, they are filled into FIFO and at some time CS goes high.
Now I get my interrupt and mark this received packet as completely received.
But I think there is now a race condition between CS going high (and pin interrupt) and SSP peripheral giving me received data.
I don't know when (how much delayed) the SSP peripheral is giving me the received data.
Workaround could be that the pin interrupt is starting a short timer, and when timer times out, then it is really done.
But there are some timing assumptions, where I am really not happy with.
Perhaps some SSP master sends CS sometimes a bit faster and then it is not working any more.
(Or I am too pessimistic here?)
I hoped I have overseen some easy way to do this...
I hoped the SSP is checking CS. It is already using it for enabling/disabling MISO (in case of multiple slaves),
so why not giving a status flag "CS went high" (which means packet end).
Best regards,
Martin