Jump to content
  • 0

How to implement I2C slave script/staticio?


WCL

Question

Hi all,

According to the discussion in this topic :

 

 

How to implement I2C slave by script/staticio?

I have an actual I2C master device and generate an I2C signal(start, slave address).

Using logic analyzer to analyze signal? How to do that in script?

If I could analyze the signal, and using staticio tool to generate an ACK?

 

Thanks

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Hello!

This is simple I2C slave realised by ROMs.
For test it you need to connect (do not forget pull up resistors):
SCL - DIO3
SDA - DIO1 & DIO10

There are two ROM blocks.
The small one - convert SDA output (DIO0) from PUSH-PULL to OPEN DRAIN (DIO10). DIO1 - SDA input, DIO0 - SDA desired output, DIO10 - SDA open drain otput.
The big one - I2C logic. You can configure truth table with help of excel file.

The state machine is like a BASIC program with string numbers with goto on the end of each.

Header:
ADDR - address of slave on I2C
ANSWER - repeated answer byte
"Program":
IDLING - keeps state and shift actual SCL & SDA to previous SCLP & SDAP.
INIT (0) - executes once at start
STOP (1) - executes STOP on I2C
START (2) - executes START & RESTART on I2C
and so on fro each bit.

Take an attention to change from READ to WRITE and back. Read is a simple match of rising SCL (SCLP=0 & SCL=1). Write needs 2 falling SCLs - first set the value the second turns back to read. So you need an intermediate state for rising SCL.

With best regards.
P.S.
For longer answer you need more ROM size. So you must use another configuration (#4 for AD2, logic: 16x16k).

I2C.dwf3work

I2C.xlsx

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...