Go Down

Topic: Does I2C send and receive in background ? (Read 601 times) previous topic - next topic

Aurélien

Hello,
A little question : does someone know if the I2C write function only in the outgoing buffer and then the data is send in background while the program runs, or does the program stop until the data is send ?
I hope my question is clear...
Thank you :)

PS : because I'm thinking about making a huge led matrix made of little 8*8 matrix driven by atmega8 modules. And I dont want the main µC to loose time sending data to atmega8. I found something to put I2C at 400kHz instead of 100kHz to make things go faster, too.

PaulS

The Arduino is a single-threaded processor. There is no "background". I hope that answers your question.

JO3RI

And you can only send 32 bytes every time you send data. if you have like 120 bytes to send, you'll have to send it in parts.
http://www.JO3RI.be

Nederlandstalige sectie - http://arduino.cc/forum/index.php/board,77.0.html -

pylon

The hardware is sending one byte without disrupting the main code. The an interupt "asks" for the next byte. The library is responsible for buffering up to 32 bytes of data, which is then sent using this "mechanism".

Nick Gammon


A little question : does someone know if the I2C write function only in the outgoing buffer and then the data is send in background while the program runs, or does the program stop until the data is send ?


If you are referring to Wire.endTransmission that blocks (waits) until the buffer is sent, if that answers your question.

Wire.send (now called Wire.write) doesn't wait, nor does it do any sending.

You could rewrite it to be non-blocking, someone may have done that already.

Quote
The Arduino is a single-threaded processor. There is no "background". I hope that answers your question.


But it can receive serial data asynchronously, because the USART has a buffer. I think the TwoWire interface must have at least a single-byte buffer, maybe more (hard to find that bit in the datasheet).

It can also send "in the background". According to the datasheet page 223:

Quote
Because the TWI is interrupt-based, the application software is free to carry on other operations during a TWI byte transfer.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Go Up