cancel
Showing results for 
Search instead for 
Did you mean: 

Problem while enabling I2C & FSMC in STM32F103ZE

grv1103
Associate
Posted on June 29, 2015 at 12:06

Hi,

I am using STM32F103ZE microcontroller. In which  communicating with external SRAM with FSMC . It is working fine.

1)Now I am trying to communicate with an IC which is connected through I2C1 (PB6 : SCL , PB7 : SDA,). But this communication is not happening while using external RAM through FSMC.

2)But I2C is working with internal RAM, and communication with that IC is happening, there is no issue.

Then I tried I2C communication with External RAM after disabling FSMC_NADV in register AFIO_MAPR2 (By setting 10th bit in AFIO_MAPR2 register). But still same problem is persisting.

Anyone have idea about it??

#i2c #fsmc
5 REPLIES 5
Amel NASRI
ST Employee
Posted on June 29, 2015 at 12:22

Hello khandelwal.gaurav,

Did you applied the workaround described in

http://www.st.com/st-web-ui/static/active/en/resource/technical/document/errata_sheet/CD00197763.pdf

:  ''it is possible to use the remap functionality available on the PB8 and PB9pins. Otherwise, disable the FSMC clock through the ''RCC_AHBENR'' register prior usingthe I2C1.''

-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.

grv1103
Associate
Posted on June 29, 2015 at 14:01

I can't remap the I2C pins because the hardware which I have only

PB6 : SCL , PB7 : SDA  are available for I2C. 

PB8 and PB9 pins are used for some other purpose.

And Since  I am using External SRAM , and my code is based on RTOS platform I can't disable FSMC clock in between.  

Is there any other solution?? 

Is AFIO_MAPR2 register available in STM32F103ZE HD device??

Amel NASRI
ST Employee
Posted on June 30, 2015 at 13:57

Hi Guarav,

Unfortunately this is a limitation in STM32F103ZE and the possible workaround is what I suggested.

Is there a way for you to free PB8 and PB9 and use other pins instead?

-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.

sajadkk
Associate
Posted on April 03, 2016 at 00:46

sajadkk
Associate
Posted on April 03, 2016 at 00:47

hello dears.

this is the real solution, i had same problem and solved it.

//VERY IMPORTANT     : fsmc must be disable and enable, before and after accessing i2c1 on portb.6 and portb.7

like this code

#define FSMC_ENABLE        delay_us(10);RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE)

#define FSMC_DISABLE    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, DISABLE);delay_us(10);

void i2c_write(unsigned char day) {

    FSMC_DISABLE;

    I2C_Write(DS1307_I2C);//,

    FSMC_ENABLE;

}

void i2c_read(unsigned char day) {

    FSMC_DISABLE;

    I2C_Write(DS1307_I2C);//,

    FSMC_ENABLE;

}