I have 2 arduino boards, the master and the slave. I m sending and receiving on the master. The slave is using both Wire.onReceive() and Wire.onRequest() functions. So basically the wire behaves like an interrupt but arduino can only handle one at a time. So this means that you have to give up one to use the other. Eg if you are sending from the master, you cant receive on the master at the same time. So I was reading from the link below that having a time delay between sending and receiving on the wire alows time to switch between sending and receiving.
By putting a delay between sending and receiving on the master works, however occasionally it doesnt work. So on the master you decide when to send and when to receive however on the slave it doesnt decide and the sending/receiving functions are simply called when ever the master decides. If you look at the sample code for the master sender to slave receiver I noticed that there is a delay in the main loop of the slave. My question is if you have a delay between sending and receiving on the master should you also have a delay between sending and receiving on the slave? Does the delay in the main loop of the slave have an effect on the send and receive interrupts that occur. Is it necessary? Its quite confusing because the interrupts occur concurrently to the main program so I really cant visualise how a delay occurs simulataneously to the interrupts? There isnt enough explaination on the arduino reference for this.