打印

stm8s eeprom 问题请教

[复制链接]
1743|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
lattice1|  楼主 | 2012-7-26 10:48 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
初始化部分,这个部分可以成功的写入,和读出来

void EEPROM_Init(void)
{  
  //unlock EEPROM
  FLASH->DUKR = 0xAE;
  FLASH->DUKR = 0x56;
  EEP_Wait_Finished();
  if ((eeprom_variable[0]=='T') && (eeprom_variable[1]=='G') && (eeprom_variable[2]==8) && (eeprom_variable[3]==0x00))
  {  
    Remote_ID[0] = E2_ReadMem(0);
    Remote_ID[1] = E2_ReadMem(1);
    Remote_ID[2] = E2_ReadMem(2);
    Remote_ID[3] = E2_ReadMem(3);
  }
  else
  {
    Remote_ID[0] = 0xaa; //第一次
    Remote_ID[1] = 0xaa;
    Remote_ID[2] = 0xaa;
    Remote_ID[3] = 0xaa;
    E2_WriteBurst(0, 4, Remote_ID);
     
    E2_ResetEEPROM();
  }
  EEP_Wait_Finished();
}




void E2_ResetEEPROM(void)
{
  EEP_Wait_Finished();
  eeprom_variable[0] = 'T';   //"TG80" is written  in the EEPROM
  EEP_Wait_Finished();
  eeprom_variable[1] = 'G';   //This allows to check later that the EEPROM content is valid.
  EEP_Wait_Finished();
  eeprom_variable[2] = 8;
  EEP_Wait_Finished();
  eeprom_variable[3] = 0x00;
  EEP_Wait_Finished();
}

在这个部分,写入ID时就是写不进去。奇怪?
if(Save_ID_标志寄存器 == 1 && RX_buf[4] == 15) //学习模式,保存ID
       {
          Save_ID_标志寄存器 = 0;
          Remote_ID[0] = RX_buf[0]; // ID
          Remote_ID[1] = RX_buf[1];
          Remote_ID[2] = RX_buf[2];
          Remote_ID[3] = RX_buf[3];
          //E2_WriteBurst(0, 4, Remote_ID);
           
         
          EEP_Wait_Finished();
          eeprom_variable[4] = Remote_ID[0];   //"TG80" is written  in the EEPROM
          EEP_Wait_Finished();
  eeprom_variable[5] = Remote_ID[1];   //This allows to check later that the EEPROM content is valid.
  EEP_Wait_Finished();
  eeprom_variable[6] = Remote_ID[2];
  EEP_Wait_Finished();
  eeprom_variable[7] = Remote_ID[3];
  EEP_Wait_Finished();
           
       }
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

99

主题

300

帖子

3

粉丝