STM8L FLASH 读写问题

2019-07-19 21:51发布

写了个stm8l52c6 的block读写代码,用的是IAR.按照官方提示步骤更改过RAM方面的配置:
- For IAR Compiler:
    1- Define a location FLASH_CODE before each code function by the mean of 
    " #pragma location = "FLASH_CODE"".
    This location is defined in the stm8l15x_flash.c file, and it's conditionned
    by IAR_RAM_EXECUTION definifition.
  2- Uncomment the "#define IAR_RAM_EXECUTION  (1)" line in the stm8l15x.h file,
    or define it in IAR compiler preprocessor to enable the FLASH_CODE location 
    definition.
  3- Edit the linker file lnkstm8l15xxx.icf available under 
    "$IAR SystemsEmbedded Workbench 6.0stm8configlnkstm8l15xxx.icf"
       by updating the line "initialize by copy { rw, ro section .tiny.rodata };"
       with the the following one:
       "initialize by copy { rw, ro section .tiny.rodata, section FLASH_CODE};".
  4- The speed optimization is required to ensure proper execution from RAM.
    -> In IAR Embedded workbench IDE Select ProjectOptionsC/C++ CompilerOptimizations
    select speed optimization
代码如下:

#pragma location="MY_RAM_FUNC"

void LPR_Ram(void)

  uint8_t i = 0;

/* To reduce consumption to minimal 
  Swith off the Flash */
  FLASH->CR1 = 0x08;
  while(((CLK->REGCSR)&0x80)==0x80);

/* Swith off the Regulator*/
  CLK->REGCSR = 0x02;
  while(((CLK->REGCSR)&0x01)==0x01);

/* Set trigger on GPIOE pin6*/ 
  WFE->CR2 = 0x04;
  GPIOE->CR2 = 0x44;
  
  for (i=0; i<100; i++);

/* To start counter on falling edge*/
//  GPIO_LOW(CTN_GPIO_PORT,CTN_CNTEN_GPIO_PIN);
  
/*Wait for end of counter */
  wfe();
  
  EXTI->SR1 |= 0x40;
  WFE->CR2 = 0x00;
  
  //Switch on the regulator
  CLK->REGCSR = 0x00;
  while(((CLK->REGCSR)&0x1) != 0x1);
}

lnkstm8l152c6.icf
initialize by copy { rw section .far.bss,
                     rw section .far.data,
                     rw section .far_func.textrw,
                     rw section .huge.bss,
                     rw section .huge.data,
                     rw section .huge_func.textrw,
                     rw section .iar.dynexit,
                     rw section .near.bss,
                     rw section .near.data,
                     rw section .near_func.textrw,
                     rw section .tiny.bss,
                     rw section .tiny.data,
                     ro section .tiny.rodata, section MY_RAM_FUNC
                     };
Embedded Workbench 6.5里面加了这个

运行之后
Error[Lc036]: no block or place matches the pattern "ro code section MY_RAM_FUNC_init in lowpower.o" 
Error[Lc036]: no block or place matches the pattern "rw code section MY_RAM_FUNC in lowpower.o" 


这个是什么原因呢?有没有遇到过这样的问题,改怎么解决啊?

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
2条回答
正点原子
1楼-- · 2019-07-20 00:13
帮顶....
snailled
2楼-- · 2019-07-20 03:35
楼主解决了吧?突然发现 这个论坛里面,好多人提问的都没有解决哦,我是新手,还没有学到flash,帮不到你。遗憾?

一周热门 更多>