![]() I put that on top of my page " Tricks that are (almost) allowed". ![]() Well, it works, but you are not supposed to do that. Yes, you can call Wire.available() in the loop() and no, that is not allowed. I hope you don't send text with variable length over I2C, that is often not needed. Is the Master also an Arduino board and did you write the sketch for the Master ? So, whats the right way to do this? How do I handle/enqueue fast incoming i2c messages and process them all without dropping data?Īssume i can process messages faster than my rx buffer will fill up, messages will just come in bursts, so no need to care about overflows necessarilly or after requestFrom(address, numBytes) ![]() Wire has an internal rx buffer, so I'd have thought I could just call Wire.available() and Wire.read() from inside my loop, but the implementation of Wire.cpp states: // must be called in: So instead I can create a buffer, and push to it from inside the ISR, and then read from loop() but thats even more susceptible to race conditions - unless I disable interrupts whilst i take a local copy of the buffer before reading it - but with interrupts off I'll miss messages. I shouldn't process it in the ISR in order to keep the interrupt slim and fast.Īnd then set this from the ISR and read it inside loop(), I might not loop fast enough to read quickly incoming messages - thus losing messages. How do I properly resolve the below issues? I've got a stream of mesasges coming into an I2C slave from its master.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |