Skip to content

nRF51822: TWI data corruption & TWI hang up sometimes #348

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

Open
Shreyas-R opened this issue Mar 18, 2019 · 5 comments
Open

nRF51822: TWI data corruption & TWI hang up sometimes #348

Shreyas-R opened this issue Mar 18, 2019 · 5 comments

Comments

@Shreyas-R
Copy link

Guys, I'm using the library for one of my projects using generic nRF51822 (v3) module where I'm using BLE peripheral (BLE UART) to send some data through I2C to some external device. I took examples from your library & built my code on that. Now I'm facing two issues:

  1. Sometimes I2C data sent is corrupt
  2. Sometimes I2C data transmission hangs nRF51822 (with SCL or SDA always low)

I did some debug & here is what I found:

  1. I'm sending multiple I2C data bytes after each interval & I found that some clock cycles or some data is not sent over I2C.
  2. Slave has fixed frequency set & clock stretching disabled so it must be caused by master only (especially SCL always low)

After going through some Nordic doc & threads, I found that BLE peripheral has higher priority & can cause issue to TWI.

  1. What & where is the priority of TWI set in the library?
  2. Is DMA enabled for TWI?
  3. Is TWI intialised with blocking or non blocking mode in the library? Where can I change it?
@dlabun
Copy link
Collaborator

dlabun commented Mar 18, 2019

I didn't write the I2C library so I may be incorrect on this, but as far as I know there's no priority set and DMA is not used. I do not know about blocking mode, you may want to review the code for yourself: https://github.com/sandeepmistry/arduino-nRF5/tree/master/libraries/Wire

There's also issue #176. That might be of some help to you as there has been reported odd behavior on the nRF51 with I2C.

@Shreyas-R
Copy link
Author

Why DMA was not implemented for nRF51 even though it supports as per docs? I see that nRF52 uses TWI manager which works on DMA. Can I use it for nRF51?

I looked myself at the code. Didn't find any reference of interrupt priority or DMA so I posted here.

Don't know whether they (#176) were using softdevice along with I2C or not. Softdevice definitely causes issues as it has highest priority. Nordic suggests to use Timeslot API or use radio notifications to time other low priority works in between. I'm trying to implement that.

@dlabun
Copy link
Collaborator

dlabun commented Mar 18, 2019

This project is based off the code base for the Arduino Zero, which does not make use of DMA. A few people have cobbled together DMA support on the Zero but I haven't seen anyone move it to the nRF.

@Shreyas-R
Copy link
Author

Can I use nRF52 wire library to implement TWIM under nRF51? Or have anybody tried that?

@dlabun
Copy link
Collaborator

dlabun commented Mar 19, 2019

You can certainly try at our own risk, I don’t know if there’s any difference between the two libraries.

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

No branches or pull requests

2 participants