AnsweredAssumed Answered

STM32L151RB I2C Busy flag always set

Question asked by giuffrida.alberto on Feb 17, 2014
Latest reply on Oct 31, 2014 by van_kuilenburg.jan

Hi!

I've a custom made board with STM32L15RB microcontroller. My I2C1 is not working well: I see the Busy flag going SET when I activate the APB1 Clock (RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);)

With a logic probe, I notice that both CLOCK and DATA are high (pullup resistors installed).

When I set them in alternate function (first I set them using PinAFConfig, and them in mode AF) they goes immediatly low. They are set at 2MHz, pushpull and nopull.

I tested to manualy force a clock signal (going up and down in out mode for CLOCK signal): the logic probe sees the square wave, but the DATA (set in AF I2C mode) wouldn't get up.

If I ignore the Busy flag (STM32 is the only master, there are three slaves), and generate a START, it wouldn't pass this piece of code"while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT));" and no interrupt are generated.

FYI, this is the clock configuration:
HSE=16MHz, PLLMUL 6, PLLDIV 3, SYSCLK 32000 , AHB PRESCALER 2, HCLK 16000, APB1 and APB2 prescaler 1 (PCLK1=PCLK2=16000).
I've configured it by using the system_stm32l1xx.c created by Clock Configuration.xls. I've also set in my preprocessor symbols this "HSE_VALUE=16000000" (I'm using KEIL uVision 4). I need to do something else to configure the HSE clock source? I'm using an external 16MHz oscillator.

I know about the errata... I'll configure the DMA... when I2C will start to work :)

Many thanks!
Alberto :)

Outcomes