简体   繁体   English

在STM32L0的IAR中初始化Eeprom

[英]Initializing Eeprom in IAR on an STM32L0

I want the eeprom to be initialized with certain values but its not working as intended. 我希望使用某些值初始化eeprom,但不能按预期工作。 What am I doing wrong: 我究竟做错了什么:

From my .icf File in IAR 从我在IAR中的.icf文件

define symbol __region_EEPROM_start__ = 0x08080030;
define symbol __region_EEPROM_end__ = 0x080807FF;
..
define region EEPROM_region = mem:[from __region_EEPROM_start__ to __region_EEPROM_end__];
..
place in EEPROM_region  {rw section .eeprom};

In my Code: 在我的代码中:

__root char dataE[] @ ".eeprom" = {0xFF};
int
main (void)
{

  init ()

yet the eeprom does not get initialized correctly, all I get in debug mode is: 但是eeprom没有正确初始化,我在调试模式下获得的只是:

0x08080000 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x08080010 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x08080020 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x08080030 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00

The EEPROM can be initialized to zero by default by compiler. 编译器默认可以将EEPROM初始化为零。 To initialize to a different value you will have to write it separately and then load it. 要初始化为其他值,您将必须分别编写然后加载。 OR do it in the main in the initialization section. 或在初始化部分的主要部分进行操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM