cancel
Showing results for 
Search instead for 
Did you mean: 

stm8l052 COSMIC Compiler EEPROM _FLASH_NCR2 not defined

andreas239955_stm1_st
Associate II
Posted on August 17, 2015 at 19:35

Hallo,

I moved my project from IAR to COSMIC and STVD and now with the COSMIC Compiler I always get the error message ''#error clnk Debug\densitometer_st.lkf:1 symbol _FLASH_NCR2 not defined ((C:\Program Files (x86)\COSMIC\32K_Compilers\CXSTM8\Lib\libm0.sm8)eepwrl.o (C:\Program Files (x86)\COSMIC\32K_Compilers\CXSTM8\Lib\libm0.sm8)eeprom.o )

 The command: ''clnk -l''C:\Program Files (x86)\COSMIC\32K_Compilers\CXSTM8\Lib''  -o Debug\densitometer_st.sm8 -mDebug\densitometer_st.map Debug\densitometer_st.lkf '' has failed, the returned value is: 1

exit code=1.''.

I searched on this topic and i found, that somehow it is necessary to manually implement this defines:

volatile char FLASH_CR1     @0x5050; /* Flash Control Register 1 */

volatile char FLASH_CR2     @0x5051; /* Flash Control Register 2 */

//volatile char FLASH_NCR2    @0x5051; /* Flash Complementary Control Reg 2 */

volatile char FLASH_PUKR    @0x5052; /* Flash Program memory unprotection reg */

volatile char FLASH_DUKR    @0x5053; /* Data EEPROM unprotection reg */

volatile char FLASH_IAPSR   @0x5054; /* Flash in-appl Prog. Status reg */

And there it starts to get strange, because my stm8l052c6 does not have a NCR2 register.

So I guess, that i need to set a correct define and the compiler takes all the necessary defines from a file.

I also checked the MCU Selection in STVD. There is the correct one selected.

As you can see, i also tried to define the NCR2 but if i do so, the write command kills the running program.

So please can someone help me with this problem. 

Thanks

Andi

4 REPLIES 4
luca239955_stm1_st
Senior II
Posted on August 17, 2015 at 20:41

Hello,

this is explained on pages 51/52 of the user manual (that is in the /doc subdirectory of the compiler).

Regards,

Luca

andreas239955_stm1_st
Associate II
Posted on August 17, 2015 at 22:20

Hello luca,

thanks for the fast reply. As it is mentioned in the manual, I manually added the library to the linker file. I attached the linker file.

And i changed the settings in STVD under ''Linker/Input'' to use a custom .lkf file, so that it is not overwritten every time. Maybe there is also another option to include thelibl0.sm8 library directly with STVD, but i could not find it in the short time.

With this step, the linker was not asking for the FLASH_NCR2 definition any more.

But anyway there is still a problem with the write procedure. The controller still stops when i try to perform a write procedure to the eeprom. Is there more to do?

And is it normal, that i still have to define FLASH_CR2 andFLASH_IAPSR by my own.

Regards,

Andi

________________

Attachments :

project_st_-_Kopie.lkf : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Htrf&d=%2Fa%2F0X0000000aY4%2FwENcG1AEkv09cQbh.tau8vlSK411CEYlJzBxi1F.LPY&asPdf=false
andreas239955_stm1_st
Associate II
Posted on August 18, 2015 at 09:56

Today I also found this instructions inside the flash-library:

===============================================================================

                         Functions to be executed from RAM

 ===============================================================================  

 

 All the functions defined below must be executed from RAM exclusively, except

 for the FLASH_WaitForLastOperation function which can be executed from Flash.

 Steps of the execution from RAM differs from one toolchain to another:

 - For Cosmic Compiler:

    1- Define a segment FLASH_CODE by the mean of '' #pragma section (FLASH_CODE)''.

    This segment is defined in the stm8l15x_flash.c file.

  2- Uncomment the ''#define RAM_EXECUTION  (1)'' line in the stm8l15x.h file,

    or define it in Cosmic compiler preprocessor to enable the FLASH_CODE segment

   definition.

  3- In STVD Select Project\Settings\Linker\Category ''input'' and in the RAM section

    add the FLASH_CODE segment with ''-ic'' options.

  4- In main.c file call the _fctcpy() function with first segment character as 

    parameter ''_fctcpy('F');'' to load the declared moveable code segment

    (FLASH_CODE) in RAM before execution.

  5- By default the _fctcpy function is packaged in the Cosmic machine library,

    so the function prototype ''int _fctcopy(char name);'' must be added in main.c

    file.

Is it necessary to execute it from RAM? 

How can i add this segement in the list and with which commands?

Could it look like this? (part out of lkf-file) I added this line by my own.

# Segment Ram:

+seg .data -b 0x100 -m 0x4ff -n .data

+seg .bss -a .data -n .bss

+seg .FLASH_CODE -a .data -n .FLASH_CODE -ic

#<END SEGMENT_CONF>

andreas239955_stm1_st
Associate II
Posted on August 20, 2015 at 19:21

I solved my problem. I forgot to unlock my EEPROM. Sorry and thanks for the first hint. This one was necessary.

Regards