Hi,
We are using Proteus to simulate the I2C in slave mode of a PIC18LF14K22 in Proteus. We noticed that the simulation is not consistent with the datasheet of the pic. See the initial post on microchip forum : https://www.microchip.com/forums/m1192092.aspx
When data has to be send by the pic to the master, the register R/nW is reset to zero after the first read which appears to be not consistent.
Best regards,
Thomas
Error with I2C slave mode simulation of PIC18LF14K22
Re: Error with I2C slave mode simulation of PIC18LF14K22
Ok, I will look at this. Too odd, however, that no one has complained to this in all these years.
If you can post some Proteus project including code proving it, this will then speed troubleshooting up.
If you can post some Proteus project including code proving it, this will then speed troubleshooting up.
Kind regards,
Ettore Arena - Labcenter Electronics.
Ettore Arena - Labcenter Electronics.
Re: Error with I2C slave mode simulation of PIC18LF14K22
Upon quick check I believe the PIC18 model is correct. The issue is in your SEQUEQNCE blocks in the I2C DEBUGGER.
The sequences :
Are simply wrong for those Not Ack flags. Correct protocol for I2C Debugger is in the Help file.
You need to replace them all with:
In particular, the read sequences 11 and 20 (restart) cause a collision condition which makes, in turn, the R/nW bit in SSPSTAT register to clear, as clearly stated by the documentation.
If you use the correct sequences and queue the sequence S 0x72 0x00 Sr 0x73 A N P you will get back:
The sequences :
Code: Select all
{SEQUENCE000=S 0x72 N 0x00 N P}
{SEQUENCE002=S 0x72 N 0x01 N P}
{SEQUENCE003=S 0x72 N 0x02 N P}
{SEQUENCE010=S 0x73 N P}
{SEQUENCE011=S 0x73 N N P}
{SEQUENCE020=S 0x72 N 0x00 Sr 0x73 N N P}
You need to replace them all with:
Code: Select all
{SEQUENCE000=S 0x72 0x00 P}
{SEQUENCE002=S 0x72 0x01 P}
{SEQUENCE003=S 0x72 0x02 P}
{SEQUENCE010=S 0x73 N P}
{SEQUENCE011=S 0x73 A N P}
{SEQUENCE020=S 0x72 0x00 Sr 0x73 A N P}
If you use the correct sequences and queue the sequence S 0x72 0x00 Sr 0x73 A N P you will get back:
Kind regards,
Ettore Arena - Labcenter Electronics.
Ettore Arena - Labcenter Electronics.
Re: Error with I2C slave mode simulation of PIC18LF14K22
Hi,
Thank you very much for the answer!! Indeed it was not clear in the doc how to send a proper sequence. That should work much better, thank you!!
Best
Thank you very much for the answer!! Indeed it was not clear in the doc how to send a proper sequence. That should work much better, thank you!!
Best