• 大小: 137KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-03
  • 语言: 其他
  • 标签: MC9S08  EEPROM  

资源简介

完整工程,基于MC8S08DZ60的EEPROM擦写读取,已经在开发板上测试成功

资源截图

代码片段和文件信息

#include  /* for EnableInterrupts macro */
#include “derivative.h“ /* include peripheral declarations */
void readEEPROM(unsigned int addressunsigned char *readbufunsigned char length);
void WriteEEPROM(unsigned int start_addrunsigned char *pDataunsigned char length);
void MCU_SetBusClock(void);    /* XOSC 4.332MHZBUS clock 8.664MHZ */
unsigned char ProgramRam[6] = {0x030x010x020x040x050x06};
unsigned char readbuf[6];

void main(void) {

  MCU_SetBusClock();
  EnableInterrupts; /* enable interrupts */
  /* include your code here */
   FCDIV=49;      //设置分频       8.664mhz/50在150k到200khz间
  WriteEEPROM(0x1400ProgramRam6); 
  readEEPROM(0x1400readbuf6);
  for(;;) 
  { __RESET_WATCHDOG();}
}
void readEEPROM(unsigned int start_addressunsigned char *readbufferunsigned char length)
{
  
      unsigned char i;
      unsigned char *p;
      for(i=0;i      {
        p = (unsigned char *)(start_address); 
        readbuffer[i]= *p;
        start_address++;
      }
      
}

void WriteEEPROM(unsigned int start_addrunsigned char *pDataunsigned char length) 
{
  unsigned char i;
  unsigned char *p;
   if(FSTAT_FACCERR==1)
    FSTAT_FACCERR=1;                  //清除错误标记
   p=( unsigned char *)(start_addr);  //指定地址
   *p=0x01;
   FCMD=0X40;                         //擦除命令
   FSTAT_FCBEF=1;                     //启动命令
   asm{                               //等待4个bus cycle
   NOP
   NOP
   NOP
   NOP
   }
   while(FSTAT_FCCF==0);                      //等待完成
   for(i=0;i   {
       if(FSTAT_FACCERR==1)
       FSTAT_FACCERR=1;
       p=( unsigned char *)(start_addr+i);    //指定地址
       *p=pData[i];                           //写入的数据
       FCMD=0X20;                     //写入命令
       FSTAT_FCBEF=1;                 //启动命令
       asm{                           //等待4个bus cycle
       NOP
       NOP
       NOP
       NOP
       }
       while(FSTAT_FCCF==0);         //等待完成
   }
}

/******************************************************************************************
| FUNCTION NAME    :  MCU_SetBusClock 
| CALLED BY        :  xxxx                                                
| PRECONDITIONS    :  xxxx                                         
| INPUT PARAMETERS :  xxxx
| OUTPUT PARAMETERS:  xxxx                                                      
| RETURN VALUE     :  xxxx
| DEscriptION      :  set MCGOUT and bus frequencyBDIV = 1 VDIV = 16 RDIV = 4 OSC = 4.332MHz
|                     MCGOUT = [(OSC / RDIV) * VDIV] / BDIV;
|                     MCGOUT = [(4.332MHz / 4) * 16] / 1 = 17.328MHz;
|                     Bus frequency = MCGOUT / 2 = 8.664MHz
| NOTE             :  xxxx                                 
|*******************************************************************************************/

void MCU_SetBusClock(void)    /* XOSC 4.332MHZBUS clock 8.664MHZ */
{

  //SOPT1 = 0;                  /* STOP WATCH DOG *

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2415  2012-08-17 11:57  eep\BDM_P&E_Multilink_CyclonePro.ini

     文件      94751  2012-08-17 12:05  eep\bin\Project.abs

     文件       1268  2012-08-17 12:05  eep\bin\Project.abs.s19

     文件      65545  2012-08-17 12:05  eep\bin\Project.map

     文件         59  2012-08-17 11:11  eep\cmd\BDM_P&E_Multilink_CyclonePro_Postload.cmd

     文件         60  2012-08-17 11:11  eep\cmd\BDM_P&E_Multilink_CyclonePro_Preload.cmd

     文件         60  2012-08-17 11:11  eep\cmd\BDM_P&E_Multilink_CyclonePro_Reset.cmd

     文件         59  2012-08-17 11:11  eep\cmd\BDM_P&E_Multilink_CyclonePro_Startup.cmd

     文件       3077  2011-09-29 09:49  eep\cmd\HCS08_OpenSourceBDM_Erase_Unsecure.cmd

     文件         59  2011-09-29 09:49  eep\cmd\HCS08_OpenSourceBDM_Postload.cmd

     文件         60  2011-09-29 09:49  eep\cmd\HCS08_OpenSourceBDM_Preload.cmd

     文件         60  2011-09-29 09:49  eep\cmd\HCS08_OpenSourceBDM_Reset.cmd

     文件         59  2011-09-29 09:49  eep\cmd\HCS08_OpenSourceBDM_Startup.cmd

     文件        856  2011-09-29 09:49  eep\C_Layout.hwl

     文件        161  2011-09-29 09:49  eep\Default.mem

     文件      73393  2012-08-17 11:11  eep\eep.mcp

     文件       4279  2012-08-17 12:05  eep\eep_Data\CWSettingsWindows.stg

     文件      12408  2012-08-17 12:05  eep\eep_Data\Standard\objectCode\main.c.o

     文件      92624  2012-08-17 11:11  eep\eep_Data\Standard\objectCode\MC9S08DZ60.C.o

     文件       7217  2012-08-17 11:11  eep\eep_Data\Standard\objectCode\Start08.c.o

     文件     298268  2012-08-17 12:05  eep\eep_Data\Standard\TargetDataWindows.tdt

     文件       1949  2011-09-29 09:49  eep\HCS08_OpenSourceBDM.ini

     文件        140  2011-09-29 09:49  eep\prm\burner.bbl

     文件       1750  2011-09-29 09:49  eep\prm\Project.prm

     文件        423  2011-09-29 09:49  eep\Sources\derivative.h

     文件       4096  2011-09-29 09:49  eep\Sources\eep.IAB

     文件        368  2011-09-29 09:49  eep\Sources\eep.IAD

     文件       4096  2011-09-29 09:49  eep\Sources\eep.IMB

     文件        368  2011-09-29 09:49  eep\Sources\eep.IMD

     文件         12  2011-09-29 09:49  eep\Sources\eep.PFI

............此处省略18个文件信息

评论

共有 条评论