cancel
Showing results for 
Search instead for 
Did you mean: 

stm32discovery board and I2C

gayathris025
Associate
Posted on April 01, 2014 at 07:58

we have been facing problem in I2C communication in STM32F407/417 discovery board. when RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1,ENABLE); command is initialized busy flag in SR2 register is set and no other communication is happening . no other flags like SB , TxE , RxNE are being set in SR1 register. 

3 REPLIES 3
chen
Associate II
Posted on April 01, 2014 at 17:06

''when RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1,ENABLE); command is initialized busy flag in SR2 register is set and no other communication is happening . no other flags like SB , TxE , RxNE are being set in SR1 register. ''

Why would turning on the clock to the I2C peripheral clock change

SB - start bit in reg

TxE - Data Reg Enpty

RxNE - Read Reg Not Empty ?

There must be I2C activity for these bits to change.

If ''busy flag'' is set - the bus is busy - check on a oscilloscope.

gayathris025
Associate
Posted on April 04, 2014 at 12:16

mohamad_armoon
Associate III
Posted on April 11, 2014 at 15:44

it would be very better if you post your code.

i think if you have busy flag problem , there are 3 assumptions :

1- you never stop your and (I2C_GenerateSTOP(I2Cx, ENABLE);)

try to reset your board. if it pass busy flag line i think the problem is i mentioned .

2- you stop the line but it the busy flag is set again.

 try : while(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_TRANSMITTED)); after I2C_GenerateSTOP(I2Cx, ENABLE); if program hanged in while the problem is your acknowledge . that you never send to slave.

3- you may send wrong address in the bus. not that if your slave address is 0x01 you have to send 0x02 for writing on slave and 0x03 for reading from it.