2012-11-28 09:22 PM
2012-11-29 06:58 AM
Did you fix the pin driver issue?
You can read the GPIO pin state using registers. You can tri-state the pin, and let the external 4K7 resistor pull up the lines. If it is not going high, then and external device on the bus is driving/clamping it low. Probe the circuit figure out which. You can clock confused I2C slave devices by driving the SCL manually, most slaves don't have an async reset, so if they get in odd states you must clock them out.2012-11-29 09:35 PM
YEs i have changed the GPIO configurations
If i probe he SCL line its always high I have no clue whats happeningvoid RCC_Configuration(void).
Here is my clock and GPIO code Pls let me know where am i wrong { RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE); }void I2C_Config(void)
{GPIO_InitTypeDef GPIO_InitStruct;
I2C_InitTypeDef I2C_InitStruct;GPIO_InitStruct.GPIO_OType = GPIO_OType_OD;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStruct.GPIO_Pin =TEMP_I2c_SDA; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz; GPIO_Init(GPIOB, &GPIO_InitStruct); GPIO_PinAFConfig(GPIOB,GPIO_PinSource7,GPIO_AF_I2C1);GPIO_InitStruct.GPIO_OType = GPIO_OType_OD;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStruct.GPIO_Pin =TEMP_I2C_SCL; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz; GPIO_Init(GPIOB, &GPIO_InitStruct); GPIO_PinAFConfig(GPIOB,GPIO_PinSource6,GPIO_AF_I2C1);I2C_InitStruct.I2C_ClockSpeed=2000000;
I2C_InitStruct.I2C_Mode=I2C_Mode_I2C; I2C_InitStruct.I2C_DutyCycle=I2C_DutyCycle_2; I2C_InitStruct.I2C_OwnAddress1=0x00; I2C_InitStruct.I2C_Ack=I2C_Ack_Enable; I2C_InitStruct.I2C_AcknowledgedAddress=I2C_AcknowledgedAddress_7bit; I2C_Init(I2C1,&I2C_InitStruct); I2C_Cmd(I2C1,ENABLE);}
2012-11-30 02:50 AM
GPIO_InitStruct.GPIO_Pin =TEMP_I2c_SDA; // Check definition, you explicitly call out the AF pin
.. GPIO_InitStruct.GPIO_Pin =TEMP_I2C_SCL; .. I2C_InitStruct.I2C_ClockSpeed=2000000; // 2 MHz ??? Otherwise initialization looks reasonable.2012-11-30 02:59 AM
Thanks Clive.
You mean to say i have to use GPIO_AF_I2C1. Currently I have defined SCL as GPIO_Pin_6 and GPIO_Pin_7 as SDA.i I have changed the frequency to 100kHz(standard mode) And these are the values i could see when i debug in I2C registers CR1->0x00000401(PE bit is set, ACK bit is set) CR2->0x0000001E(Freq is set with this value) OAR1->0x00004000(ADD is 0x00) OAR2->0x0000000(ADD2 is 0x00) DAR will be written with the data i send SR1 is 0 SR2->0x00000002 Busy bit is set CCR->0x00000096 TRISE->0x0000001F2012-11-30 03:30 AM
Try enabling before initializing.
I2C_Cmd(I2C1,ENABLE); I2C_Init(I2C1,&I2C_InitStruct);2012-11-30 03:49 AM
2012-11-30 03:50 AM
2012-12-07 02:32 AM
Hi,
Try to reset the I2C after enabling its clock: /* Reset I2C1 IP */ RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, ENABLE); /* Release reset signal of I2C1 IP */ RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, DISABLE); Let me know the result. Cheers, STOne-322015-11-25 01:23 PM
Hi,
I am facing the same problem. i'm betting an ACK failure after sending the slave address. So I am not sure what the problem is. I have attached a screenshot of the data being transmitted when viewed on a logic analyzer. Please help.2016-02-29 11:50 AM
Hi, maybe it is a little old thread but i was having the same problems with the start getting stuck. What i did to fix was to enable the i2c clock AFTER i call GPIO_PinAFConfig() because seems to be there is a glitch that makes the i2C module to stay with the BUSY bit on when you enable first the clocks.
Hopefully it helps somebody struggling as i was