프로그램 다운로드시 eeprom 초기화하기

기술노트 32477

아키텍처:

STM8

컴포넌트:

compiler

업데이트:

2018-02-28 오전 1:47

Introduction

This Technical Note discusses IAR Embedded Workbench for STM8 and EEPROM initialization. An assignment like:

__eeprom char array[] = {0X1C,0X1F,0X9F,0XFF};

.. generates the compiler error message

Error[Ta004]: __eeprom variable must be __no_init

.. which means that eeprom variables can't be assigned a value at compile time.

Solution

Declare the variable as a static char. Place it in eeprom section "my_eeprom".

char array[]@ "my_eeprom" = {0X1C,0X1F,0X9F,0XFF};

and update the linker configuration file for example:

place in Eeprom             { rw section .eeprom.noinit,
rw section my_eeprom };

Note that

The 'array' variable does not get the __eeprom memory attribute. This means reading from 'array' will be ok, but the compiler will generate ordinary __near memory writes for any assignments (usually with no effect at all). You have to call your own routines for writing to the eeprom, and it is up to you to ensure that there are no ordinary C assignments.

Background

The __eeprom variables must be __no_init.
The reason for this is that initialized __eeprom variables would require different initialization routines from normal variables.
We presumed that the EEPROM memory would be used for persistent storage, so there would be no need for automatic initialization.
It is up to the application (or system) to initialize the EEPROM memory.
Nevertheless, support for initialized __eeprom variables is planned in a future release of IAR Embedded Workbench for STM8.


All product names are trademarks or registered trademarks of their respective owners.

죄송하지만, 당사 사이트에서는 Internet Explorer를 지원하지 않습니다.보다 편안한 사이트를 위해 Chrome, Edge, Firefox 등과 같은 최신 브라우저를 사용해 주시길 부탁드립니다.