cancel
Showing results for 
Search instead for 
Did you mean: 

I2C S/W-implementation (AN1045)

wolfgang2399
Associate II
Posted on September 11, 2006 at 08:28

I2C S/W-implementation (AN1045)

3 REPLIES 3
wolfgang2399
Associate II
Posted on September 11, 2006 at 05:33

Hi,

is there anybody with experiences in I2C S/W-application.

I took the example of AN1045 and ported it to my Lite29-project.

In fact it works, but there are some questions which I'd like to discuss.

Thanks for reply

WoRo

laurent239955_stm1
Associate II
Posted on September 11, 2006 at 06:26

Hi Woro,

The best is to ask your question(s), then may be someone can answer !

BR

Laurent

wolfgang2399
Associate II
Posted on September 11, 2006 at 08:28

Hi Henry,

great that you replied immediately.:-D Here are my questions:

- In the ROUTINE wait_Ack there is an ambiguous sequence (twice the same code):

if(ValBit(PADR,SDA)) /* Test of SDA level, if high -> pb */

 

...

 

delay(2);

 

if(ValBit(PADR,SDA)) ....

 

...

 

delay(5);

 

1st: What's the sense?

2nd: What means ''-> pb''

3rd: Does your application work while you leave the code? I must skip it!!!

- In the ROUTINE I2C_nAck the line

ClrBit(PADR,SDA); /* The master pulls the SDA line high */

the code or the comment seem not to be correct.

Any suggestion?

- To avoid spurious changes of the output register values while using bclr or bset commands with PADR, I'd like to fix the output values before changing a port to output:

ClrBit(PADR,SCL); SetBit(PADDR,SCL);

Or better:

disableInterruptMask; ClrBit(PADR,SCL); SetBit(PADDR,SCL); enableInterruptMask;

Any experiences?

Sorry Henry, I have no idea to your problem with the odd numbers.:-[

- Did anybody else find further ambiguities or problems with the given code or has tuned it for better performance??

Thanks in advance

WoRo