Giter Club home page Giter Club logo

Comments (9)

JF002 avatar JF002 commented on August 15, 2024 1

Ok, I can reproduce it! I just have to wait longer.
The fix from @TT-392 seems to work, even though I would have preferred to be able to actually fix the issue instead of using this kind of workaround.

For info, the 5000 loop iterations correspond to ~160550 CPU cycles, which corresponds to ~2.5ms @64mhz.

Now, I need to check that the code behaves correctly when the twi transaction is aborted.

from infinitime.

Avamander avatar Avamander commented on August 15, 2024

tt_392 on Matrix said:

I ended up just waiting for the thing to lock up, then turn off twim, force the pins back in the right position, and turn twim on again

from infinitime.

JF002 avatar JF002 commented on August 15, 2024

From our talk in the chat room, it looks like the TWI device is buggy and locks itself from time to time.
Adding a timeout in the driver and completely reset the TWI device when we detect a hard lock seems the only solution.

from infinitime.

TT-392 avatar TT-392 commented on August 15, 2024

Here is how I ended up fixing it btw
https://github.com/TT-392/TT-time/blob/master/src/external/infinitime/i2c_pine.c

As far as I understood from the nordic forums (allthough I can't seem to find the specific thread anymore). It seems that you specifically have to forcefully reset your SCL and SDA pins.

from infinitime.

JF002 avatar JF002 commented on August 15, 2024

@TT-392 Thanks for the fix! It looks like the TWI drivers hangs when SPI and TWI are heavily used at the same time... I guess you couldn't find another solution that would prevent the device from locking?

from infinitime.

rafacouto avatar rafacouto commented on August 15, 2024

Investigating this issue, I think it could be related to Nordic's hardware anomaly 109. Moreover, it could be also the same problem described on issue lupyuen/pinetime-rust-mynewt#24 affecting SPIM.

There are some workarounds in the mentioned document. Handling peripheral IRQ to wake up seems the best one in this case. See example code in 3.8.3 TWIM workaround subsection.

from infinitime.

JF002 avatar JF002 commented on August 15, 2024

I've just had a look at the anomaly referenced by @rafacouto. This is pretty bad : a race condition inside the CPU. And the workaround are quite complex to put in place.

However, the anomaly specifies that SPIM TX and TWIM TX are affected by the anomaly. TWIM RX is not referenced. But RX could be locked because TX caused the anomaly just before?

Anyway, I'm trying to reproduce it so that I can analyze that issue further... with no result for now
I've tried using InfiniPaint (paint app) from develop, and the pong game developed by @ColdBrewCaffine (https://github.com/ColdBrewCaffine/Pinetime/tree/Run-dev-2).

Soooo... can you help me find a way to reproduce this issue more or less reliably?

from infinitime.

JF002 avatar JF002 commented on August 15, 2024

I've implemented the fix recommended by @TT-392, it's running fine for more than 4 hours with the pong game developed by Electrolyte.
See this branch : https://github.com/JF002/Pinetime/tree/fix-twi-hang and this PR : #111

from infinitime.

JF002 avatar JF002 commented on August 15, 2024

Fixed in #111

from infinitime.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.