cancel
Showing results for 
Search instead for 
Did you mean: 

I2C problem

aleksander
Associate
Posted on August 07, 2008 at 08:48

I2C problem

6 REPLIES 6
aleksander
Associate
Posted on May 17, 2011 at 12:26

I have probles to run I2C2.

When i set START bit in I2C2_CR1 register the pin PB11(I2C2_SDA) goes low, but SB bit is never set in I2C2_SR1.

I2C2Test()

{

while((I2C2_SR2 & 0x02) != 0); //wait for I2C to be free

I2C2_CR1 |= I2C2_CR1_START; //start

while((I2C2_SR1 & 0x01) == 0); // wait for SB

I2C2_DR = DIMMER2_ADDRESS; // Never get to this point

.........

.........

}

Here is Init function :

I2C2Init()

{

I2C2_CR1 = I2C2_CR1_PE | I2C2_CR1_ACK; // turn on I2C and set ACK

I2C2_OAR1 = 0x4001;

I2C2_OAR2 = 0x0000;

I2C2_CCR = 0x028;

I2C2_TRISE = 0x03;

}

Any idea ??

Regards, Aleksander.

lanchon
Associate III
Posted on May 17, 2011 at 12:26

hi alex,

I don't have time to check your code, but here is the lowest level of my I2C stack if you want to take a look. it's working fine on I2C2 at 400kbps.

bob239955
Associate II
Posted on May 17, 2011 at 12:26

FYI - Your kind attachment seems to be empty/corrupt.

[ This message was edited by: bobz on 19-03-2008 15:02 ]

lanchon
Associate III
Posted on May 17, 2011 at 12:26

BTW, there's a ''problem'' with the I2C hardware. I reproduce a comment form the files here in case someone's dealing with the same issue:

// Some byte counts cannot be received safely by a polling process that can be preempted

// due to shortcomings in the peripheral hardware design, but a single byte can.

(at least that's my current understanding of the situation.)

lanchon
Associate III
Posted on May 17, 2011 at 12:26

alex, I just downloaded i2c.zip from my post and tested its contents and everything seems to be alright. please try to download it again, maybe clearing your browser cache first.

alexanderlohr9
Associate II
Posted on May 17, 2011 at 12:26

In which way could I establish a connection between 2 I2C channels from the STR9 Board.