cancel
Showing results for 
Search instead for 
Did you mean: 

I2C STOP SDA does not go back to high level

julien
Associate II
Posted on May 06, 2008 at 12:01

I2C STOP SDA does not go back to high level

5 REPLIES 5
julien
Associate II
Posted on May 17, 2011 at 12:34

Hello,

I'm using the um0427 library, and after a stop the SCL is at the high level, but the SDA not go back to high level,

On the scope trace we can also see the glitchs already evoked (http://www.st.com/mcu/forums-cat-6701-23.html)

gpio/i2c config

*******

/* Configure I2C1 pins: SCL and SDA ------*/

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;

GPIO_Init(GPIOB, &GPIO_InitStructure);

/* I2C1 configuration ---*/

I2C_DeInit(I2C1);

I2C_InitStructure_1wire.I2C_Mode = I2C_Mode_I2C;

I2C_InitStructure_1wire.I2C_DutyCycle = I2C_DutyCycle_2;

I2C_InitStructure_1wire.I2C_OwnAddress1 = I2C1_SLAVE_ADDRESS7;

I2C_InitStructure_1wire.I2C_Ack = I2C_Ack_Enable;

I2C_InitStructure_1wire.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;

I2C_InitStructure_1wire.I2C_ClockSpeed = 50000;

I2C_Init(I2C1, &I2C_InitStructure_1wire);

/*---------------*/

code

*************************

void resetds2482(void){

/* Send I2C1 START condition */

I2C_GenerateSTART(I2C1, ENABLE);

/* Test on I2C1 EV5 and clear it */

while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT));

I2C_Send7bitAddress(I2C1, DS2482, I2C_Direction_Transmitter);

/* Test on I2C1 EV6 and clear it */

while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED));

/* Envoi du Reset */

I2C_SendData(I2C1, DRST);

/* Test on I2C1 EV8 and clear it */

while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED));

/*Si la commande a réeussi le 2482 répond par un octet on Restrart l'I2C en Reception*/

I2C_GenerateSTART(I2C1, ENABLE);

while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT));

I2C_Send7bitAddress(I2C1, DS2482, I2C_Direction_Receiver);

/* Test on EV6 and clear it */

while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED));

/*Recuperation du Status Registger ---*/

regvalue = I2C_ReceiveData(I2C1);

while(I2C_GetFlagStatus(I2C1, I2C_FLAG_RXNE));

/* Send I2C1 STOP Condition */

I2C_GenerateSTOP(I2C1, ENABLE);

GPIOB->BSRR = GPIO_Pin_7;

myDelay(80000);

}

[ This message was edited by: julien.massot on 06-05-2008 12:24 ]

[ This message was edited by: julien.massot on 06-05-2008 12:26 ]

viktor3
Associate II
Posted on May 17, 2011 at 12:34

Did you check my post (http://www.st.com/mcu/forums-cat-6701-23.html) ?

julien
Associate II
Posted on May 17, 2011 at 12:34

it's seems that it's the restart who cause this problems, how can i do a restart whithout stop ?

jj
Associate II
Posted on May 17, 2011 at 12:34

Hi,

Scope pictures are great! Have not used I2C on STM32 yet

but have with other ARM.

Check that you have proper pull-up R on SDA line AND that

''no other'' device on your I2C bus is pulling SDA down.

Good luck.

julien
Associate II
Posted on May 17, 2011 at 12:34

It's a Cortex M3 from ST (STM32f103),

The problem is that the acknoledge must be disable for the last byte reveived , i corrected it and it's works..