apollo0226 wrote:Do we get any official support from espressif ?Or any sample code?I do need this.

next time i will post the doing with a smaller base.yes you will get a sample code here next timeso keep smile - but you have to studdy i2c protokoll first.there is nothing mysteriose on the code.and there comes no end solution for your homework.you have to optimate the code then by your self and needs.

what is need/comes:

GPIO setup for openDrainif you not know about this, you must studdy first the difference to openDrain

GPIO set valu Gpio set ACK, NACKif you not know about this, you must studdy first, how you can give an Low Value to an OpenDrainPin and a high.to give a LOW by set the gpio to low is not enough!

ISR / Interrupting and comparing Start, Stop, 7bit, 10bit... Adress, Dataif you not know about this, you must studdy first Interrupting with GPIOand how you can - set- compare- clear

I know how to set the GPIO and ISR. Now I set the SDA a low active Interrupt.So when the Interrupt first trigger , it must be start condition, because SCL is high, SDA is low.So I get the 8 bit and set ACK, this is slave address and R/W bit.I compare it , is this my slave address? if no , set the NACK and exit, If yes, go to check R/W bit to Read or Write. If Read , get more data.

My question is when do I stop ? Checking SCL and SDA both high (STOP condition) in the SDA ISR ?Do the SCL need to set to Interrupt ? if yes , active high or low? What do it do in SCL ISR?

because you know what is a start and because you know what is a stopyou can make the procedure like you need.

apollo0226 wrote:So when the Interrupt first trigger , it must be start condition, because SCL is high, SDA is low.

sry no.it triggers allways, must allways tiggerin the isr then you check is it a startif is a start, then check if addr matchif addr match then check again is it not a stopthen check addr matchif addr match then againthen check again is it not a stopif you have checked addrthen check it is a write or a read cmd..

apollo0226 wrote:So I get the 8 bit and set ACK, this is slave address and R/W bit.

no sry.you must allway first check is it no stopyou know what stop isso check get the pin valu of scl and check against sda,if sda is high, then it is a stop

apollo0226 wrote:I compare it , is this my slave address? if no , set the NACK and exit, If yes, go to check R/W bit to Read or Write. If Read , get more data.

sry no you only make ack,no NACKnack is allways, when you do no ACK.ok?you do not a NACK

NACK is given by the OpenDrain Config thats the "trick"you only config the Gpio to OpenDrainand set the value for it to high ( NACK )if you not change the pin valu for a ACKthen automatically the master read a NACKyou have not to set the PIN Value for the GPIO to Highits configured high as OpenDrain.you only change the config for the GPIO if you give a ACKand this can read the master because it is set as Opendrain too.ok?

apollo0226 wrote:

a) My question is when do I stop ? b) Checking SCL and SDA both high (STOP condition) in the SDA ISR ?c) Do the SCL need to set to Interrupt ? if yes , active high or low? What do it do in SCL ISR?

d) If you give us the sample code , it will help a lot.

a) as master? or as slave?b) no, first goes sda high, and scl is low at this time, this is a stop, and yes in the ISR.c) yes - if you do by HW yes, you have to check SDA AND SCL,you can do a small only by SDA, this was my start too. and make a software ISR - this is the simplest way until you not go faster

but if you go faster, then your software "time stretch" is not detailed enough to handle SDA on right timming.

d) no sir you have to learn first how the I2C protokoll works, then come back and we start again step by step.i know, you can do it. your thinking is not to much wrong on the start and stop. be sure this is in your head on right function,then come back and we work together i am sure on end of week the base stand here.

come on guy!you need my example not - i am sure.

best wishesrudi

step 1) post your code how you do setup opendrain the gpio for I2C slavethis is the first step.lets go - show me..

Documentation

About Us

Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.