2011-05-29 03:41 AM
Hi, all
I2c2 start bit generation fail - after timeout of 10 ms I2C_FLAG_SB = RESET = 0 but I2c1 work well read and write. anyone can help ?
More details: 10k poll up on each pin. Clock Speed - 50000.I2c2 start bit generation fail - after timeout of 10 ms I2C_FLAG_SB = RESET = 0 but I2c1 work well read and write.
More details: 10k poll up on each pin. Clock Speed - 50000. my code: /******************************************************************************* * Function Name : ISC_Config * Description : Configure the ISC interface * Input : None * Output : None * Return : None *******************************************************************************/ void I2C_Config(void) { GPIO_InitTypeDef GPIO_InitStructure; I2C_InitTypeDef I2C_InitStructure; /* Configure the SDA And the SCL line to alternate function Open Drain */ I2C_DeInit(I2C1); 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(I2C_PORT, &GPIO_InitStructure); /* Configure the I2C peripheral */ I2C_SoftwareResetCmd(I2C1,ENABLE); I2C_SoftwareResetCmd(I2C1,DISABLE); I2C_Cmd(I2C1, DISABLE); I2C_InitStructure.I2C_Mode = I2C_Mode_I2C; I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2; I2C_InitStructure.I2C_OwnAddress1 = I2C_SLAVEADDRESS; I2C_InitStructure.I2C_Ack = I2C_Ack_Enable; I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; I2C_InitStructure.I2C_ClockSpeed = I2C_CLOCKSPEED; I2C_Init(I2C1, &I2C_InitStructure); I2C_Cmd(I2C1, ENABLE); I2C_AcknowledgeConfig (I2C1, DISABLE); I2C_DeInit(I2C2); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10|GPIO_Pin_11; GPIO_Init(I2C_PORT, &GPIO_InitStructure); /* Configure the I2C peripheral */ I2C_SoftwareResetCmd(I2C2,ENABLE); I2C_SoftwareResetCmd(I2C2,DISABLE); I2C_Cmd(I2C2, DISABLE); I2C_Init(I2C2, &I2C_InitStructure); I2C_Cmd(I2C2, ENABLE); I2C_AcknowledgeConfig (I2C2, DISABLE); } /******************************************************************************* * Function Name : GenerateStartCondition * Description : Generates the I2C start condition * Input : None * Output : None * Return : TRUE - Start condition generated successfuly. FALSE - otherwise *******************************************************************************/ static BOOL GenerateStartCondition(void) { BOOL bRes=FALSE; BOOL bStatusChangeTimeout=FALSE; I2C_GenerateSTART (I2C2, ENABLE); if (TriggerTimeoutCounter(I2C_STATUS_CHANGE_TIMEOUT_MSEC)) { while ((I2C_GetFlagStatus (I2C2,I2C_FLAG_SB)== RESET) && !bStatusChangeTimeout) { if (IsTimeoutExpired()) bStatusChangeTimeout=TRUE; } if (!bStatusChangeTimeout) bRes=TRUE; } return bRes; } main() { return GenerateStartCondition(); //it's return false } #i2c2-start-bit-generation-fail-in-stm32f103rb2011-06-06 07:52 AM
Hi,
Are you working with STM32 EVAL board, if yes which is this eval board ???2011-06-06 09:13 AM
Where do you initialize the clocks?
2011-06-12 03:05 AM
2011-06-12 03:39 AM
Hi,
I attached an example that run on STM32F10X-128K-EVAL and illustrate the problem. Tank you very much ________________ Attachments : STM32F103_i2c2_bug.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I18c&d=%2Fa%2F0X0000000biu%2FlQAiIQ_THhOsgMfN74P2SVMyFm9C2giWai47nhiwNFg&asPdf=false2011-06-12 06:58 AM
I attached an example that run on STM32F10X-128K-EVAL and illustrate the problem.
The I2C_Config() function in the attached project does not initialize the pins for the I2C2 port.
Generally I'd put all the pin configurations in one place, like GPIO_Config()
2011-06-13 03:19 AM
2011-06-13 10:18 AM
Is the STM32F10X-128K-EVAL (STM3210B-EVAL) even wired suitably to sustain a second I2C bus? Aren't the PB10 & PB11 pins connect to the smart card interface?
Follow Up : Initializing and testing two I2C buses on the VL Discovery, without additional hardware/pull-ups, I2C1 fails your test, I2C2 passes your test.
2011-07-05 11:03 PM
Try examples available at
also refer the errata sheet avaialble for I2C. its a good document available on internet and will give you an insight of problem and its solution I2C optimized example availble at