9:17 pm
September 24, 2015
Have been trying to morph the I2C Master/Slave examples into a loop-back configuration: Master -> Slave -> Master -> serial monitor.
Seems like the attached code should be close, but doesn’t work. I wonder about the I2C Write String vi in i2C Reply Interrupt; not sure about a constant for the slave address as trying to transmit to the Master.
Suggestions?
Jim
2:38 am
September 24, 2015
4:02 pm
September 24, 2015
5:09 pm
March 12, 2015
Ok there is a fundamental issue here. Sending data back from a Slave to the Master is a little different because the Master has to initiate all transfers. You cannot just reply back from the Slave when the Master sends a message. You may want to read up a bit more on I2C Master Reader mode here. But take a look at the DS1307 Real Time Clock.vi example, which is code for a Master. Inside Read RTC Time and Format.vi the Master is requesting time info from a slave RTC device using the same method you would need to use.
On the Slave side, you need to create a Request Interrupt to capture requests from Master "Request From" messages. This is very similar to setting up the Receive Interrupt but you use I2C Attach Request Interrupt.vi. Then the Master has to request data from the slave using I2C Request From.vi. This will cause the Request interrupt on the slave side to go off in which you can then transfer data back to the Master using I2C Write String.vi as you are now. On the master side you would read all bytes after sending Request From.
6:36 pm
September 24, 2015
Steffan,
I had looked at the DS1307 Real Time Clock.vi but let it ‘slip away’; think I kind of rebelled against the I2C Request From.vi not 'telling' the slave what to send. The Write/Request/Read sequence could go into a subvi, but (I understand) would require a global variable to get to the reply. The RTC example is what I want to do anyway: get values from registers on an I2C slave.
I appreciate your help!
Jim
25
1 Guest(s)