2014-02-17 02:55 PM
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 :)2014-02-19 02:11 AM
Mohsen
''i have the same problem with my I2C(busy flag always is set) in stm32f103. do you have any idea about how to fix it?'' No. I have no idea. You need to a) start another thread b) give more details - code and circuit2014-02-21 07:56 AM
Checked: I've now 3 identical boards, and all with the same problem: there shouldn't be any problems.
I've checked also the USART1, just to be sure: using the pin as an output works well, sending bytes via USART library put the line low and no more else. So also USART1 don't work. Do you have any suggestions to resolve the I2C problem (and maybe this will fix the USART one)?2014-02-24 01:24 AM
I am a bit lost now. To recap :
''Checked: I've now 3 identical boards, and all with the same problem'' So, you still have the problem. As soon as the I2C is initialised - both lines go low? ''I've checked also the USART1, just to be sure: using the pin as an output works well, sending bytes via USART library put the line low and no more else. So also USART1 don't work.'' Not sure what you are trying to do here. USART (or RS232) is a completely different comms protocol. It will not work in the same was as I2C. You cannot expect the line (in fact RS232 has Tx and Rx where as I2C has Data and a clock) to behave in the same way! ''Do you have any suggestions to resolve the I2C problem'' Have you tried disconnecting your slave.2014-10-29 01:26 AM
I have
the same problem
.
How did you
solve
it
?
You
solve
it
?
2014-10-31 02:16 AM
Hi Stanislav,
It should be better to create a new thread in which you describe exactly what you are facing as problem, used hardware, snippet code...Regarding this particular case: I suggest to enable I2C clock after configuring GPIOs.If my suggestion doesn't fix your issue, please go back to my first proposal & create a new thread.-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2014-10-31 03:32 AM
Hi,
I had the same problem with the busyflag after init, there are 2 solutions: -start the I2C clock after setting the pins RCC->APB1ENR |= (1UL << 21); // Enable I2C1 clock -before init I2C registers, do a reset: I2C1->CR1 |= 0x8000; I2C1->CR1 &= (uint16_t) ~((uint16_t) 0x8000);