AnsweredAssumed Answered

STM32F105RC I2C2 always busy

Question asked by pullin.owen on Jan 3, 2013
Latest reply on Feb 20, 2015 by steudte.sven
Hi,
I hope someone can help.
I have got the I2C1 peripheral working fine with the above chip, but when I try and initialize the I2C2 peripheral, the busy flag is always set. Does anyone have any ideas?
My code:

RCC->APB2ENR |= 0x00000008; // Enable GPIOB clock
GPIOB->CRL = 0xFF444434; // Set GPIOB configuration register low (pins PB6 and PB7 for I2C1)
GPIOB->CRH = 0xBBB4FF44; // Set GPIOB configuration register high (pins PB10 and PB11 for I2C2)
 
// I2C 1 Initialize (works fine)
RCC->APB1ENR |= 0x00200000; // Enable i2c 1 clock
I2C1->CR1 = 0x0480; // Set acknowledge enable
I2C1->CR2 = 0x0138; // Set clock frequency and error interrupt enabled
I2C1->CCR = 0x0119; // Set i2c standard mode and duty cycle 100khz
I2C1->TRISE = 0x0039; // Set maximum rise
I2C1->CR1 |= 0x0001; // Enable i2c 1
 
// I2C 2 Initialize
RCC->APB1ENR |= 0x00400000; // Enable i2c 2 clock <--------- After this line is called the BUSY flag of SR2 is set and remains so
I2C2->CR1 = 0x0480; // Set acknowledge enable
I2C2->CR2 = 0x0138; // Set clock frequency and error interrupt enabled
I2C2->CCR = 0x0119; // Set i2c standard mode and duty cycle 100khz
I2C2->TRISE = 0x0039; // Set maximum rise
I2C2->CR1 |= 0x0001; // Enable i2c 2

Many Thanks.


Outcomes