0

I have an Atmega328 programmed using the Arduino software and libraries (but is standalone on on a board in the TSOP package) without bootloader and with ISP programming). I am using the Wire library to act as an I2C peripheral, where I implement (and register) the requestEvent and receiveEvent callbacks.

Is it possible to determine, either during the requestEvent callback or after it at some point, how many bytes were read by the master before it sent a NACK?

asked Aug 29, 2016 at 21:06

1 Answer 1

1

You can't.

The master will have to inform the slave how many bytes to transfer, or the master will have to query the slave how many bytes there are to receive.

answered Aug 29, 2016 at 21:21
5
  • I understand that the protocol doesn't specify that. I'm interested in getting the number of bytes that were actually sent by the slave until the master sent a NACK instead of an ACK, as I specified originally in the question (be it through another callback, by calling a Wire function, etc), after the send actually completes. Commented Aug 29, 2016 at 21:25
  • *actually completes at the physical level, after the master sends the NACK. Commented Aug 29, 2016 at 21:31
  • You have no access to that level of information through the API. You can count how many times your callback is called, but that's as close as you get. You would have to work out some way of knowing what is the first transfer though. Commented Aug 29, 2016 at 21:33
  • You would have to work entirely at the register level and implement your own I2C code. Commented Aug 29, 2016 at 21:33
  • OK, that clarification answers the question perfectly. Commented Aug 29, 2016 at 21:38

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.