I can't help think I'm missing something here! And I probably should know better.
I'm trying to make use of the i2c protocol and am having trouble sending data out - receive onto the master is ok. One 4k7 pullup per i2c rail.
I have a 18M2 acting as the "master" reading a number of sensors; and one 28X2 and two 40X2 acting as "slaves". The 28X2 reads data on its input pins and sends it to the master (no problem). This data, together with more data read by the 18M2 is then combined and output to the two 40X2 devices - only it doesn't get received.
I was hoping to use the SETINT or SETINTFLAGS command to cause an interrupt only when new data needs to be read by the two 40X2's. Looking at the SETINT command, I can see a comment about SETINT input,mask,port - port being A,B,C,D - I am beginning to presume that this makes use of an otherwise spare input port (8 pins) on the 40X2's. No chance! No spare pins, all in use.
Just where does the "flag" byte come from? Does it arrive via the i2c data channel? or does it, using the SETINT command, as it might appear by checking the syntax checker, make use of a whole set of input pins? Totally confused!
On the master 18M2 - all chips running at 16Mhz:
hi2csetup i2cmaster, %10100000, i2cfast_16, i2cbyte
hi2cout 42,(b0,b1) ; question, where does the "42" here represent? scratchpad or standard bx variables? Surely it's pointing at a location on the receiving end
On the slave#1 40X2:
hi2csetup i2cslave, %10100000
setintflags %01000000,%01000000 ; or just setint
...code...
goto main
;
interrupt:
hi2cin 42,(b42,b43)
bptr=42 ; save in scratchpad 42,43
;Homesensorin=@bptrinc ; sensors1-8 (b42) - from master b0
get @bptr,homesensorin
inc bptr
;Homesensor2in=@bptr ; sensors (b43) - from master b1
get @bptr,homesensor2in ; both the above lines of code have been tried
hi2clast=0 ; reset pointer
hi2cflag=0 ; reset flag
setintflags %01000000,%01000000
return
I've tried not bothering with the interrupt: routine and just letting it receive data as part of the normal program (putting that code in the interrupt routing direct into the program listing) - nothing gets received, whether I use bptr or ptr as pointers to read the incoming data. Connections (SDA/SCL) have been checked and are good (and the right way round!).
Both 40X2's run a test/check program to test their own inputs/outputs and are fine.
Where am I going wrong? No doubt it's staring me in the face, but I just can't see it.
Thanks in advance......
I'm trying to make use of the i2c protocol and am having trouble sending data out - receive onto the master is ok. One 4k7 pullup per i2c rail.
I have a 18M2 acting as the "master" reading a number of sensors; and one 28X2 and two 40X2 acting as "slaves". The 28X2 reads data on its input pins and sends it to the master (no problem). This data, together with more data read by the 18M2 is then combined and output to the two 40X2 devices - only it doesn't get received.
I was hoping to use the SETINT or SETINTFLAGS command to cause an interrupt only when new data needs to be read by the two 40X2's. Looking at the SETINT command, I can see a comment about SETINT input,mask,port - port being A,B,C,D - I am beginning to presume that this makes use of an otherwise spare input port (8 pins) on the 40X2's. No chance! No spare pins, all in use.
Just where does the "flag" byte come from? Does it arrive via the i2c data channel? or does it, using the SETINT command, as it might appear by checking the syntax checker, make use of a whole set of input pins? Totally confused!
On the master 18M2 - all chips running at 16Mhz:
hi2csetup i2cmaster, %10100000, i2cfast_16, i2cbyte
hi2cout 42,(b0,b1) ; question, where does the "42" here represent? scratchpad or standard bx variables? Surely it's pointing at a location on the receiving end
On the slave#1 40X2:
hi2csetup i2cslave, %10100000
setintflags %01000000,%01000000 ; or just setint
...code...
goto main
;
interrupt:
hi2cin 42,(b42,b43)
bptr=42 ; save in scratchpad 42,43
;Homesensorin=@bptrinc ; sensors1-8 (b42) - from master b0
get @bptr,homesensorin
inc bptr
;Homesensor2in=@bptr ; sensors (b43) - from master b1
get @bptr,homesensor2in ; both the above lines of code have been tried
hi2clast=0 ; reset pointer
hi2cflag=0 ; reset flag
setintflags %01000000,%01000000
return
I've tried not bothering with the interrupt: routine and just letting it receive data as part of the normal program (putting that code in the interrupt routing direct into the program listing) - nothing gets received, whether I use bptr or ptr as pointers to read the incoming data. Connections (SDA/SCL) have been checked and are good (and the right way round!).
Both 40X2's run a test/check program to test their own inputs/outputs and are fine.
Where am I going wrong? No doubt it's staring me in the face, but I just can't see it.
Thanks in advance......