cancel
Showing results for 
Search instead for 
Did you mean: 

I2C to AT24C64

noval
Associate II
Posted on February 08, 2017 at 10:35

i want to using External EEPROM via I2C on STM32F051R8T6.

but i always get error when compile it.

can someone tell me or help me ?

8 REPLIES 8
david lion
Associate II
Posted on February 08, 2017 at 13:41

maybe can we have compilation error ?

Imen.D
ST Employee
Posted on February 08, 2017 at 14:07

Hello

klen.klen

,

It will be difficult to help you on your issue unless you provide more details about your case and error that you have,localize where the code hangs/stop,identify what is the problem that you see.

Also,you can share your code with user forum to get more help.

Did you checked the I2C examples available in the STM32packages?

Refer to this thread

https://community.st.com/0D50X00009Xke3SSAR

and thisapplication note

http://www.st.com/content/ccc/resource/technical/document/application_note/2e/d4/65/6b/87/dd/40/25/DM000499pdf/files/DM000499pdf/jcr:content/translations/en.DM000499pdf

would be helpful for you, it provides the EEPROM emulation driver in STM32F0.

Hope this helpsyou.

Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
noval
Associate II
Posted on February 22, 2017 at 09:39

hy, sorry my computer were re-installed

I forget to backup all of my data

so, all of my program has lost

can you help what i have to do on AT24C64?

Shashank TS_2
Associate II
Posted on January 22, 2018 at 07:29

Hello, Am using STM32F0 uC for interfacing with a AT24C64. I am not able to write sequentially to the EEPROM after one page, i.e 32 Bytes. Can someone please if the logic is wrong.

This is the code:

data[0]=0x00; //First word address 8bit

data[1]=0x00; //Second word address 8bit

for(i=2;i<34;i++)

{

data[i]=0x11;

}

HAL_I2C_Master_Transmit(&hi2c1, EEPROM_ADDRESS<<1, data, 34, 50); //data is int type,34 is number bytes of data

data[0]=0x00; //First word address 8bit

data[1]=0x20; //Second word address 8bit// Next Page

for(i=2;i<34;i++)

{

data[i]=0x22;

}

HAL_I2C_Master_Transmit(&hi2c1, EEPROM_ADDRESS<<1, data, 34, 50); //data is int type,34 is number bytes of data

while (1)

{

/* USER CODE END WHILE */

data[0]=0x00;

data[1]=0x00;

HAL_I2C_Master_Transmit(&hi2c1, EEPROM_ADDRESS<<1, data, 2, 50); //data is int type pointing to first address here

for(i=0;i<32;i++)

{

HAL_I2C_Master_Receive(&hi2c1, EEPROM_ADDRESS<<1, &dataout[i], 1, 50);//maximum is 32 byte data locations

}

data[0]=0x00;

data[1]=0x20;

HAL_I2C_Master_Transmit(&hi2c1, EEPROM_ADDRESS<<1, data, 2, 50); //data is int type pointing to first address here

for(i=0;i<32;i++)

{

HAL_I2C_Master_Receive(&hi2c1, EEPROM_ADDRESS<<1, &dataout_1[i], 1, 50);//maximum is 32 byte data locations

}

}

T J
Lead
Posted on January 22, 2018 at 08:46

hi this looks incorrect:

for(i=0;i<32;i++)

{

HAL_I2C_Master_Receive(&hi2c1, EEPROM_ADDRESS<<1, &dataout[i], 1, 50);//maximum is 32 byte data locations

}

I think you need,

HAL_I2C_Master_Receive(&hi2c1, EEPROM_ADDRESS<<1, &dataout[0], 32, 50);//maximum is 32 byte data locations

Posted on January 22, 2018 at 08:55

I tried this out it doesnt work.

It is basically considering one byte at a time for 32 times and i think the issue is with the Transmit before the while loop where am writing to the EEPROM

Posted on January 22, 2018 at 12:11

You might need to insert some delays between programming pages. It says in the datasheet: 

BYTE WRITE: A write operation requires two 8-bit data word addresses following the device address word and acknowledgment. Upon receipt of this address, the EEPROM will again respond with a zero and then clock in the first 8-bit data word. Following receipt of the 8-bit data word, the EEPROM will output a zero and the addressing device, such as a microcontroller, must terminate the write sequence with a stop condition. At this time the EEPROM enters an internally-timed write cycle, tWR, to the nonvolatile memory. All inputs are disabled during this write cycle and the EEPROM will not respond until the write is complete (see Figure 12-2 on page 11).

Posted on January 22, 2018 at 12:53

Awesome that works for me. Thank you so much.