how to read and write eeprom for stm8s003k3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-01-06 05:57 AM
Posted on January 06, 2017 at 14:57
void main()
{ GPIOB-> DDR |= (1<<2); //output GPIOB-> CR1 |= (1<<2); //push-pull type output // GPIOB-> DDR &= ~(1<<7); //input // GPIOB-> CR1 |= (1<<7); //pull-up without interrupt GPIOC-> DDR &= ~(1<<2)|(1<<3); //input GPIOC-> CR1 |= (1<<2)|(1<<3); //pull-up without interrupt ///* Define FLASH programming time */
FLASH_SetProgrammingTime(FLASH_PROGRAMTIME_STANDARD);/* Unlock Data memory */
FLASH_Unlock(FLASH_MEMTYPE_DATA);/* Read a byte at a specified address */
add = 0x4000; val = FLASH_ReadByte(add);/* Program complement value (of previous read byte) at previous address + 1 */
val_comp = (uint8_t)(~val); FLASH_ProgramByte((add + 1), val_comp);/* Check program action */
val = FLASH_ReadByte((add + 1)); if (val != val_comp) { /* Error */// OperationStatus = 0; /* OperationStatus = PASSED, if the data written/read to/from DATA EEPROM memory is correct */ /* OperationStatus = FAILED, if the data written/read to/from DATA EEPROM memory is corrupted */ while (1) { } }}
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-03-06 02:26 AM
Posted on March 06, 2017 at 11:26
Thank you for your code !
It is helpful for the community.
Regards,
Simon
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.