EEPROM Read problem
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2009-08-27 8:54 AM
Posted on August 27, 2009 at 17:54
EEPROM Read problem
This discussion is locked. Please start a new topic to ask your question.
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 6:04 AM
Posted on May 17, 2011 at 15:04
Hi,
I follow the example of the firmware libraty to read/write/erase one byte of the EEPROM, I can write a byte, but fail to readback, my code u8 c; u32 add = 0x4000; FLASH_SetProgrammingTime(FLASH_PROGRAMTIME_STANDARD); FLASH_Unlock(FLASH_MEMTYPE_DATA); FLASH_ProgramByte(add, 0xa5); c = FLASH_ReadByte((u32)add); FLASH_ProgramByte(add,0x5a); c = FLASH_ReadByte((u32)add); FLASH_EraseByte(add); FLASH_ProgramByte(add,0x5a); c = FLASH_ReadByte(add); I'm sure the FLASH_ProgramByte() executes correctly (I also read back using STVP), but the FLASH_ReadByte() always returns ''0'', what's wrong? JasonOptions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 6:04 AM
Posted on May 17, 2011 at 15:04
Hi Jason,
When unlocking the data eeprom you should wait until the DUL flag in the flash status register is set (data eeprom ready), FLASH_Unlock(FLASH_MEMTYPE_DATA); while (FLASH_GetFlagStatus(FLASH_FLAG_DUL) == RESET); if you execute your code from RAM, if the address is in data eeprom memory you should wait until the HVOFF flag in the status register is set (end of high voltage) FLASH_ProgramByte(add, 0xa5); while (FLASH_GetFlagStatus(FLASH_FLAG_HVOFF) == RESET); c = FLASH_ReadByte((u32)add); and if the address is in flash program memory you should wait until the EOP flag in the status register is set (End of programming). FLASH_ProgramByte(add, 0xa5); while (FLASH_GetFlagStatus(FLASH_FLAG_EOP) == RESET); c = FLASH_ReadByte((u32)add); Normally your code works fine if you use the default clock system HSI/8 (lower execution speed) Regards mozra [ This message was edited by: mozra27 on 26-08-2009 23:11 ]Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 6:04 AM
Posted on May 17, 2011 at 15:04
Hi mozra,
Thanks for your reply. I'vd try to read the EEPROM in flash, but failed. But I can read the EEPROM in ram. regards, JasonOptions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 6:04 AM
Posted on May 17, 2011 at 15:04
Hi jason,
What is the clock speed used in your application? if you use a clock higher than 16MHz you should set the wait state option byte. Thanks to verify this point regards mozra