Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed I2C delay bug #123

Merged
merged 2 commits into from
Jun 20, 2016
Merged

Fixed I2C delay bug #123

merged 2 commits into from
Jun 20, 2016

Conversation

mikehamer
Copy link
Contributor

This delay bug was two-fold:

  1. Wrong loop delay
    • The loop delay was (I assume, based on a comment in i2cdev.h) set for the CF1, and not updated for the CF2. The CF2 runs these loops ~3.5x faster, so the delays were much shorter than expected. I'm not sure if this was a problem, but things seem to be more robust after this change.
    • The new loop speeds were timed using the DWT->CYCCNT to count clock cycles.
  2. Overflow caused hangs
    • For some reason, it occasionally occurred that the delay variable would (due to it being a uint32_t and being decremented) underflow, wrapping to the maximum value.
    • The loop was changed to increment the value and terminate on all values greater than the target, rather than only on 0.

Signed-off-by: Mike Hamer [email protected]

This delay bug was two-fold:

1. Wrong loop delay
 - The loop delay was (I assume) set for the CF1, and not updated for the CF2. The CF2 runs these loops ~3.5x faster, so the delays were much shorter than expected. I'm not sure if this was a problem, but things seem to be more robust after this change.
 - The new loop speeds were timed using the DWT->CYCCNT to count clock cycles.

2. Overflow caused hangs
 - For some reason, it occasionally occurred that the delay variable would (due to it being a uint32_t and being decremented) underflow, wrapping to the maximum value.
 - The loop was changed to increment the value and terminate on all values greater than the target, rather than only on 0.

Signed-off-by: Mike Hamer <[email protected]>
@ataffanel ataffanel merged commit 81c6437 into bitcraze:master Jun 20, 2016
@ataffanel
Copy link
Member

Looks good and tested. I merge it. Thanks.

@ataffanel ataffanel modified the milestone: next release Jun 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants