Error with I2C slave mode simulation of PIC18LF14K22

Discussion on both general simulation and Proteus VSM microcontroller simulation.
Post Reply
ThomasLM
Professional User
Posts: 2
Joined: Wed 2021-12-08 18:39

Error with I2C slave mode simulation of PIC18LF14K22

Post by ThomasLM »

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
Ettore
Labcenter Staff
Posts: 2932
Joined: Fri 2006-03-03 11:56
Location: Milan
Contact:

Re: Error with I2C slave mode simulation of PIC18LF14K22

Post by Ettore »

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.
Kind regards,
Ettore Arena - Labcenter Electronics.
Ettore
Labcenter Staff
Posts: 2932
Joined: Fri 2006-03-03 11:56
Location: Milan
Contact:

Re: Error with I2C slave mode simulation of PIC18LF14K22

Post by Ettore »

Upon quick check I believe the PIC18 model is correct. The issue is in your SEQUEQNCE blocks in the I2C DEBUGGER.

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}
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:

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}
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:
Immagine 2021-12-09 143942.jpg
Immagine 2021-12-09 143942.jpg (30.56 KiB) Viewed 2480 times
Kind regards,
Ettore Arena - Labcenter Electronics.
ThomasLM
Professional User
Posts: 2
Joined: Wed 2021-12-08 18:39

Re: Error with I2C slave mode simulation of PIC18LF14K22

Post by ThomasLM »

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
Post Reply