Giter VIP home page Giter VIP logo

Comments (8)

SidLeung avatar SidLeung commented on August 15, 2024

Please provide Sketch output and the expected output. Thanks.

from arduinocore-arc32.

vshymanskyy avatar vshymanskyy commented on August 15, 2024

For example, millis() sometimes returns value which is less then previous calls, and then returns to normal on the next call.
This looks like interrupt locking problem, and is reproducible not only with millis().
This happens regularly when IMU or BLE is used frequently.

from arduinocore-arc32.

eriknyquist avatar eriknyquist commented on August 15, 2024

@vshymanskyy the millis function reads a counter that requires a regular interrupt to be updated.
In the sample code shown at the link above, CurieIMU.readMotionSensor is being called from interrupt context; This function, like most CurieIMU functions, involves communicating with the BMI160 via SPI, so it takes up a lot of time. So much time that you apparently miss a bunch of timer interrupts, while hanging around in interrupt context waiting for data from the IMU. I strongly recommend not to call CurieIMU functions from interrupt context. Same goes for BLE.

Really, anything that involves slow hardware comms, or communication with an external device, you should never run it in interrupt context.

from arduinocore-arc32.

eriknyquist avatar eriknyquist commented on August 15, 2024

@vshymanskyy can you show us some code please? without it, I will assume that you are doing the same thing that hsuenaga is doing on the forum link you provided (calling long-running / blocking IMU/BLE methods in interrupt context).

If this is the case, then a common solution is to modify your callback function so that all it does is set a global flag. Then in each iteration of loop(), you check if the flag has been set, and if so, you call your blocking BLE function, or whatever it is you need to do. In this way, you get out of interrupt context as quickly as possible and do the slow stuff during normal execution.

from arduinocore-arc32.

vshymanskyy avatar vshymanskyy commented on August 15, 2024

@eriknyquist , yes I think I have a bit different case.
I'll try to make a minimal sketch showing the problem -> but it will take some time. I think a week or so. Thanks!

from arduinocore-arc32.

eriknyquist avatar eriknyquist commented on August 15, 2024

@vshymanskyy I'll be here!

from arduinocore-arc32.

eriknyquist avatar eriknyquist commented on August 15, 2024

@vshymanskyy any updates on this?

from arduinocore-arc32.

eriknyquist avatar eriknyquist commented on August 15, 2024

@vshymanskyy closing the issue due to a lack of response. Feel free to re-open if you ever return to it.

from arduinocore-arc32.

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.