cancel
Showing results for 
Search instead for 
Did you mean: 

STM32f207 I2C to m24LR64 eeprom

ano2
Associate
Posted on August 29, 2012 at 14:20

Hi

I'm trying to write and read data to a m24LR64 eeprom using I2C on STM32f207

I can read data from the eeprom, but when i try to write data to the eeprom, it always writes 0xff og the memory address i'm trying to write.

this is my I2C config:

/* RCC Configuration */

/*I2C Peripheral clock enable */

RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C2,

ENABLE

);

/*SDA GPIO clock enable */

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF,

ENABLE

);

/*SCL GPIO clock enable */

//RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, ENABLE);

/* Reset I2Cx IP */

RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C2,

ENABLE

);

/* Release reset signal of I2Cx IP */

RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C2,

DISABLE

);

/* GPIO Configuration */

/*Configure I2C SCL pin */

GPIO_InitStructure.

GPIO_Pin

= I2C_EEPROM_SCL_PIN;

GPIO_InitStructure.

GPIO_Mode

=

GPIO_Mode_AF

;

GPIO_InitStructure.

GPIO_Speed

=

GPIO_Speed_2MHz

;

GPIO_InitStructure.

GPIO_OType

=

GPIO_OType_OD

;

GPIO_InitStructure.

GPIO_PuPd

=

GPIO_PuPd_NOPULL

;

GPIO_Init(GPIOF, &GPIO_InitStructure);

/*Configure I2C SDA pin */

GPIO_InitStructure.

GPIO_Pin

= I2C_EEPROM_SDA_PIN;

GPIO_Init(GPIOF, &GPIO_InitStructure);

/* Connect PXx to I2C_SCL */

GPIO_PinAFConfig(GPIOF, GPIO_PinSource0, GPIO_AF_I2C2);

/* Connect PXx to I2C_SDA */

GPIO_PinAFConfig(GPIOF, GPIO_PinSource1, GPIO_AF_I2C2);

I2C_DeInit(I2C2);

/*!< I2C

Struct

Initialize */

I2C_InitStructure.

I2C_Mode

= I2C_Mode_I2C;

I2C_InitStructure.

I2C_DutyCycle

= I2C_DutyCycle_2;

I2C_InitStructure.

I2C_OwnAddress1

= 1;

I2C_InitStructure.

I2C_Ack

= I2C_Ack_Enable;

I2C_InitStructure.

I2C_ClockSpeed

= 400000;

I2C_InitStructure.

I2C_AcknowledgedAddress

= I2C_AcknowledgedAddress_7bit;

/* I2C Initialization */

I2C_Init(I2C2, &I2C_InitStructure);

I'm using the STM32_i2c_ee.c function to read and write

status = I2C_EE_PageWrite((

uint8_t

*)data,0x0000,0x04);

I2C_EE_BufferRead((

uint8_t

*) dataRead,0x0000,0x04)

#stm32-i2c-eeprom
1 REPLY 1
ano2
Associate
Posted on August 29, 2012 at 14:26

See attached files for pin output