Skip to content

boards: Fix CC2420 RXFIFO overflow#1304

Merged
thomaseichinger merged 1 commit intoRIOT-OS:masterfrom
thomaseichinger:fix_cc2420_rxfifo_of
Jun 30, 2014
Merged

boards: Fix CC2420 RXFIFO overflow#1304
thomaseichinger merged 1 commit intoRIOT-OS:masterfrom
thomaseichinger:fix_cc2420_rxfifo_of

Conversation

@thomaseichinger
Copy link
Copy Markdown
Member

Attempts to implement CC2420 ISR to handle RXFIFO overflow compliant to datasheet.

Contains changes for:

  • z1
  • telosb
  • wsn430-v1_4

fixes #315

@thomaseichinger thomaseichinger added this to the FIX ME FIRST milestone Jun 10, 2014
@rousselk
Copy link
Copy Markdown
Contributor

Compilation fails on WSN430-v1.4. Can you see into it?

@thomaseichinger
Copy link
Copy Markdown
Member Author

forgot to include header and define for DEBUG() statement. Should be fixed now.

@thomaseichinger
Copy link
Copy Markdown
Member Author

Travis is happy again.

@miri64 miri64 modified the milestones: Release NEXT MAJOR, FIX ME FIRST Jun 12, 2014
@rousselk
Copy link
Copy Markdown
Contributor

@thomaseichinger Please exceuse me for the delay in my reaction, I've been busy with exam preparations last week. I should be more active again as of now.
Concerning this PR, ACK from me. I think you can squash it right away.
Maybe should we get another ACK to be sure... @OlegHahm what is your opinion?

@thomaseichinger thomaseichinger modified the milestones: FIX ME FIRST, Release NEXT MAJOR Jun 23, 2014
@thomaseichinger
Copy link
Copy Markdown
Member Author

Changed the milestone since it fixes a "FIX ME FIRST" issue.
@rousselk never mind, I'm the last one to complain about comment latencies :-)
@OlegHahm could you check?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is only true if both interrupts are pending. Shouldn't it be rather:

if (((P1IN & CC2420_FIFOP_PIN) != 0) && (P1IFG & CC2420_GIO0_PIN) != 0)

-> GIO0 goes low, while FIFOP is still high?

@thomaseichinger
Copy link
Copy Markdown
Member Author

TL;DR:
After discussing this topic with @OlegHahm today we agreed that the existing implementation for TelosB and Z1 are already the most robust ones. As a result I changed the ISR for wsn430-v1_4 to harmonise interrupt handling.

In the timing chart below two cases are described

  1. In this (upper) case multiple packets arrive in very short time so the MCU cannot read a whole packet before reception of a 2nd packet has finished. Taken this case FIFOP pin signals the reception of a second packet but is cleared by reading data from the RXFIFO for the first packet. Continuing, a third packet arrives triggering the overflow interrupt. Now there is data of a complete packet (p2) and a fraction of another (p3) in the RXFIFO. One could argue that reading the data for p2 by reading the first byte (packet length) could be possible but this wouldn't be the case for p3. Due to the fact that the FIFO pin is inactive we can't verify that all data specified in the packet length is actually in the RXFIFO so reading could include undefined data. This is especially the case if RXFIFO is overflown already by p2. As a result we concluded that dismissing maybe valid data from the RXFIFO is safer than reading undefined data.
  2. This (lower) case should describe the most common case, where data of a received packet can be processed by the MCU in time so no overflow appears and all is fine. \o/

@rousselk Do you agree with our argumentation?

cc2420 time chart

@rousselk
Copy link
Copy Markdown
Contributor

@thomaseichinger To sum up: yes.
In detail:
1). Yes, this is a limitation of the chip: there is only room for one packet in both transmission and reception. If good network drivers can gracefully manage the former to avoid any clash, the latter depends on two consecutive packets never to arrive too closely timewise... On CC2420, we have the ability to play on the threshold of unread bytes in receive buffer (FIFOP_THR bits in the IOCFG0 register), to have the FIFOP signal go up earlier if we found this problem to occur to frequently. By default, FIFOP goes high when at least 64 bytes of unread data are in the RX FIFO (cf. CC2420 manual pages 33, 34, and 72).

However, I don't think this will be much of a problem: we will receive corrupted data ONLY if we read the RXFIFO bytes slower than the transceiver receives and writes them into its buffer; however, 802.15.4 is a (relatively) slow protocol (250 kbit/s, which mean each byte is received from the medium in 32 microseconds); since the MSP430 UART drives the SPI communication with the transceiver at half the MCU speed, that is: at least 1 MHz on TelosB and circa 4 MHz on Z1, we can quite safely assume that reading bytes from CC2420 will be done faster that the transceiver receives them.
This means we should only suffer from this problem if we begin to read a packet after the transceiver has begun to overwrite it with new one, but before the new packet has finished arriving. Since we use interrupts to react to packet arrival (FIFOP), this situation is quite unlikely...

2). This is the trouble-free case where we can read all the incoming packet before the next one begins to arrive. For the reasons cited hereabove, I think we will almost always be in this situation.

@rousselk
Copy link
Copy Markdown
Contributor

So: if @OlegHahm acks, I can merge this PR, maybe after a squash.

@OlegHahm
Copy link
Copy Markdown
Member

ACK - merge or squash, I'll leave it to you, @thomaseichinger.

TelosB, wsn430-v14, Z1
@thomaseichinger
Copy link
Copy Markdown
Member Author

squashed and go

thomaseichinger added a commit that referenced this pull request Jun 30, 2014
@thomaseichinger thomaseichinger merged commit 9ce538f into RIOT-OS:master Jun 30, 2014
@thomaseichinger thomaseichinger deleted the fix_cc2420_rxfifo_of branch June 30, 2014 12:02
@rousselk
Copy link
Copy Markdown
Contributor

rousselk commented Jul 1, 2014

Nice! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cc2420: RXFIFO overflow is not handled correctly

4 participants