⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eeprom.c

📁 知能车源码,CCD采样道路,飞思卡尔智能车比赛源码.
💻 C
字号:
#include <hidef.h>      // common defines and macros 
#include <mc9s12dg128.h>  //    derivative information  

#define uchar unsigned char
#define uint  unsigned int

 
 
void write(uint add, uint con)   //写con 入 add 地址中
{
 unsigned int  *eeaddr;                //eeprom pointer
 
 eeaddr=(volatile unsigned int*)(add);
 // ramaddr=(volatile unsigned int*)(0x100a);
 
 while(!(ECLKDIV&0x80))      //whether the eclkdiv has been writen once after rest
	   {}
	      
 while(!(ESTAT&0x80))        //whether the command buffer is empty
     {}
 while(!(EPROT&0x80))        //whether the eeprom is enabled to program or erase
     {}
 *eeaddr=con;
 ECMD=0x20;
 ESTAT|=0x80;
       
 while(!(ESTAT&0x40))        //whether the command is complete
	       {}
}

uint read (uint add)      //read a data from eeprom
{
 uint ret;
 ret = *(volatile word *) add; 
// *Data = *(volatile byte *) Addr
 return ret;
}                                     //*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -