打印
[STM8]

stm8 FLASH EEPROM 块读写问题

[复制链接]
8260|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
sj0611002269|  楼主 | 2012-3-28 13:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 sj0611002269 于 2012-3-28 13:56 编辑

写了个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 Systems\Embedded Workbench 6.0\stm8\config\lnkstm8l15xxx.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 Project\Options\C/C++ Compiler\Optimizations
    select speed optimization


下面是代码:
#include "stm8l15x.h"
#define Flash_Block_Size 128
void Clock_Init(void);
void Flash_Eeprom_Rradwrite_Init(void);
void Flash_Eeprom_Readwrite_Test(void);

void main(void)
{

/*设置内部时钟16M为主时钟*/
  Clock_Init();
  Flash_Eeprom_Rradwrite_Init();  
  Flash_Eeprom_Readwrite_Test();
    enableInterrupts();
  FLASH_Lock(FLASH_MemType_Data);
}
void Clock_Init(void)
{
  CLK_HSICmd(ENABLE);
  CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_HSI);
  CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1);
}
void Flash_Eeprom_Rradwrite_Init(void)
{
  FLASH_SetProgrammingTime(FLASH_ProgramTime_Standard);
  FLASH_Unlock(FLASH_MemType_Data);
}
void Flash_Eeprom_Readwrite_Test(void)
{
  ErrorStatus OperationStatus;
  u32 add,start_add=0,stop_add=0;
  u16 block;
  u8 i=0;
  u8 WriteBuffer[Flash_Block_Size];

  /*Flash_EEprom write and read */
  /*fill the buffer in RAM */
  for (i=0;i<Flash_Block_Size;i++)WriteBuffer=0x12;
  /*block 0 is the first block of Data memor :address is 0x1000*/
  block=0;
  FLASH_ProgramBlock(block,FLASH_MemType_Data,FLASH_ProgramMode_Standard, WriteBuffer);
  FLASH_WaitForLastOperation(FLASH_MemType_Data);
  
  /*check the programed block*/
  start_add = FLASH_DATA_EEPROM_START_PHYSICAL_ADDRESS;
  stop_add= FLASH_DATA_EEPROM_START_PHYSICAL_ADDRESS + (u32)Flash_Block_Size;  
  for (add = start_add;add<stop_add;add++)
  {
    if(FLASH_ReadByte(add) != 0x12)
      /*error*/
      OperationStatus = ERROR;
    else
      OperationStatus = SUCCESS;   
  
  }
}

问题:make 时出现error
Error[Lc036]: no block or place matches the pattern "ro code section FLASH_CODE_init in stm8l15x_flash.o"
Error[Lc036]: no block or place matches the pattern "rw code section FLASH_CODE in stm8l15x_flash.o"

哪位大侠能帮助解决呀!搞了一上午了。。。
沙发
liyh0404cc| | 2012-5-25 15:52 | 只看该作者
请问楼主解决了没有呀,我也遇到了这个问题

使用特权

评论回复
板凳
dghidt| | 2012-5-29 15:42 | 只看该作者
写之前要去掉写保护功能,具体的命令是多少啊?我用的是华邦的W25Q64,它有两个状态寄存器

使用特权

评论回复
地板
szxugp| | 2013-4-15 17:33 | 只看该作者
请问楼主解决了没有呀,我也遇到了这个问题

使用特权

评论回复
5
xiaosi204| | 2014-8-29 15:14 | 只看该作者
LZ是怎么解决的?我也是一直在这里出错

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

1

帖子

0

粉丝