I know little about how I2C is supposed to behave so I don’t know if I have a problem or not. I’d like to ask for opinions as to whether my situation is “normal” or whether some improvement is possible. If this is typical behavior I’ll be satisfied; if it’s not and should be better, I’ll start looking deeper.
I have a 20X2 at 16MHz operating as master and a 28X2 at 32MHz operating as slave. Task-wise, the 20X2 pretty much loafs along, but the 28X2 has a demanding, continuous task and there are no PAUSEs in the main loop.
The I2C on the slave 28X is set up to hardware interrupt when data arrives in the scratchpad – two bites at locations 0 and 1. The 28X2 then reads the data and adjusts main loop operating parameters based on that new data.
Here is the issue: The only way I can get data transferred reliably from the 20X2 to the 28X2 is to send it three times consecutively with PAUSE 20s between each transmission. By doing this, the data transfer appears to be perfect as far as I can tell. Without the three transmissions it gets very unreliable. Also, pauses of less than 20 also seem to make the transfer unreliable. Why does it work so well with repeated transmits and rarely works with a single transmit?
Transfer verification by having the master read back the slave scratchpad doesn’t work at all. I would like to have a verification process whereby the master reads the slave’s scratchpad to verify that the information reached the slave, however I cannot read the slave from the master to verify the information arrived safely. When I try to query, all I get is 255, 255.
So, given the fully-occupied state of the slave, is this reasonable behavior or should I look for a problem somewhere that is preventing the system from working properly? The I2C code I’m using in both the slave and the master are straight from working examples posted in the forum and seems to be working with the above caveats. Some of the examples of I2C code in the forum have short pause commands scattered around but I cannot make sense of the logic of them so don’t know if I2C needs pauses anywhere or not.
I have a 20X2 at 16MHz operating as master and a 28X2 at 32MHz operating as slave. Task-wise, the 20X2 pretty much loafs along, but the 28X2 has a demanding, continuous task and there are no PAUSEs in the main loop.
The I2C on the slave 28X is set up to hardware interrupt when data arrives in the scratchpad – two bites at locations 0 and 1. The 28X2 then reads the data and adjusts main loop operating parameters based on that new data.
Here is the issue: The only way I can get data transferred reliably from the 20X2 to the 28X2 is to send it three times consecutively with PAUSE 20s between each transmission. By doing this, the data transfer appears to be perfect as far as I can tell. Without the three transmissions it gets very unreliable. Also, pauses of less than 20 also seem to make the transfer unreliable. Why does it work so well with repeated transmits and rarely works with a single transmit?
Transfer verification by having the master read back the slave scratchpad doesn’t work at all. I would like to have a verification process whereby the master reads the slave’s scratchpad to verify that the information reached the slave, however I cannot read the slave from the master to verify the information arrived safely. When I try to query, all I get is 255, 255.
So, given the fully-occupied state of the slave, is this reasonable behavior or should I look for a problem somewhere that is preventing the system from working properly? The I2C code I’m using in both the slave and the master are straight from working examples posted in the forum and seems to be working with the above caveats. Some of the examples of I2C code in the forum have short pause commands scattered around but I cannot make sense of the logic of them so don’t know if I2C needs pauses anywhere or not.