Go Down

Topic: I2C locking with any mor than 3 bytes sent (Read 808 times) previous topic - next topic

Nick Gammon

Quote
I have attempted significant delays (3ms) after the Wire.read()s thinking slower might be better.


Adding delays will make things much, much worse. Using delay() inside an ISR is not recommended, and is quite likely to hang the code as it waits for the time to elapse, which it won't notice because the timer is not checked inside an ISR.

Once you are in the receiveEvent all the data is available. You don't need to do Wire.available, you don't need to delay. It's all there waiting in the Wire buffer.

However as I said above you can't do serial prints ... well you can, if you don't mind the program hanging. ;)

Workinonit

Thanks so much for the advice... I will be spending the day tomorrow working on it..I WILL BE LESS WORDY!  I will report back. 

As always...
Workinonit!

Workinonit

This seems to work!  Removing all the serial comm and everything seems to be working!  Thanks so much for the help! 

I would only normally have that in the code during development.  Then remove it later...I will be taking it into consideration for future testing!

As always...
Workinonit!

Go Up