I2C mm problem
jgjonola
Posts: 27
Hey guys,
I am using the multi master plus dual uart virtual perf. and changing it to suit my needs.· I have run into a problem.· It gets stuck while checking weather it has lost arbitration.· If i comment out the arbitration lines the program works fine (I have only one master right now, plan to add another).· Also, i have found that while it is stuck, if i take the pull up resistor off and then put it back on, it starts working.· (im guessing that is making the data line go low and then high again.)· Any suggestions?
Thanks,
John Gjonola
I am using the multi master plus dual uart virtual perf. and changing it to suit my needs.· I have run into a problem.· It gets stuck while checking weather it has lost arbitration.· If i comment out the arbitration lines the program works fine (I have only one master right now, plan to add another).· Also, i have found that while it is stuck, if i take the pull up resistor off and then put it back on, it starts working.· (im guessing that is making the data line go low and then high again.)· Any suggestions?
Thanks,
John Gjonola
Comments
Please post your multimaster program so we can check.
regards peter
Thank you,
John Gjonola·
··bank·I2CM···;1 ; Select Master I2C bank
··mov·w,I2CM_port_buf··;1
··and·w,#%00000011··;1·;keep current SDA and SCL direction
··or·w,#%00000100··;1·;pin2 is input
··mov·!i2c_port,w··;1 ; Update the I2C port with the buffered port data
regards peter
·
I will try that out later tonight!
Your the best!
John Gjonola
I made the change that you suggested, but it still has the same problem. If i take out the arbitration code, then it works, if not, it just hangs until you disconnect the data line and then reconnect it.
Thanks,
John
RA_init··equ·%11110100 ··;SX18/20/28/48/52 port A latch init·;could the problem be here?????????????????
The latch bits 0 and 1 must be 0, so when direction bits 0 and 1 are 0, output is low,
and when direction bits 0 and 1 are 1, output is pulled high by the external 4.7k ohm
pullup resistors. lines SDA and SCL must have 4.7k pullups)
All the changes are done in the attached code.
regards peter
··sb·I2CM_lost_arb···; if arbitration was lost then wait a while and try again
··jmp·@:Ive_lost_arb···;IF I COMMENT OUT THIS LINE AND THE LINE BEFORE IT (IN THE READ AND WRITE PARTS OF THE
·······;PROGRAM, IT READS AND WRITES JUST FINE, IF NOT, I MUST PHYSICALLY DISCONNECT THE
·······;PULL UP RESISTOR ON THE SDA LINE AND RECONNECT IT FOR THE PROGRAM TO WORK.
Arbitration is lost if I2CM_lost_arb is set,
so it should be:
··snb·I2CM_lost_arb···; if arbitration was lost then wait a while and try again
··jmp·@:Ive_lost_arb···;(jump if I2CM_arb_lost set) IF I COMMENT OUT THIS LINE AND THE LINE BEFORE IT (IN THE READ AND WRITE PARTS OF THE
·······;PROGRAM, IT READS AND WRITES JUST FINE, IF NOT, I MUST PHYSICALLY DISCONNECT THE
·······;PULL UP RESISTOR ON THE SDA LINE AND RECONNECT IT FOR THE PROGRAM TO WORK.
regards peter
Another dangerous construction is
··snb·I2CM_NACK···; Check for no acknowledge
··jmp·@do_I2C_W···; try again
(similar constructions also in Read[noparse]:)[/noparse]
If for some reason an I2C slave does not acknowledge, your program enters
an infinite loop. You should really have a timeout on this. When you timeout,
and not lost arbitration, issue STOP sequence on I2C bus.
regards peter
Thanks again,
John Gjonola
·
with your pin assignments. Its always good to check and understand the code
you use (if you didn't write it, it may take some time to understand, but it will pay off)
Test the code with your pin assignments and if it then works
you could notify sxlist.com (you should test with at least 2 masters accessing
the same eeprom but different areas on that eeprom)
regards peter
·