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

📄 ee_module.c

📁 PIC_Hi-Tech_C_Mike_Pearces_I2C_routines Microchi PIC_Hi-Tech C_I2C_for_EEPROM_24LC01B Code
💻 C
字号:
unsigned char eedata_readbyte(unsigned char addr){  EEADR = addr;    EEPGD = 0;  CFGS = 0;  RD = 1;  return(EEDATA);}//non- interrupt driven writesvoid eedata_writebyte(unsigned char addr, unsigned char byte){  char istat;  EEADR = addr;  EEDATA = byte;  EEPGD = 0;  CFGS = 0; WREN = 1;  istat = GIE;  GIE = 0;  EECON2 = 0x55;  EECON2 = 0xAA;  WR=1;  GIE = istat;  // reenable interrupt  while (WR) ;  // wait for write to complete  EEIF = 0; WREN = 0; //clear interrupt flag, write enable}//Write string to DATA EEPROMchar eedata_writestr(unsigned char *s, unsigned char addr){  char c;  while(*s) {    eedata_writebyte(addr,*s);    // verify    c = eedata_readbyte(addr);    if (c != *s) return(1);    addr++;    s++;  }  // write end of string  eedata_writebyte(addr,*s);  c = eedata_readbyte(addr);  if (c != *s) return(1);  return(0);}//Read string from DATA EEPROMunsigned char eedata_readstr(unsigned char *s, unsigned char addr, unsigned char max){  unsigned char c,cnt;  cnt = 0;  do {    c = eedata_readbyte(addr);    addr++;    *s = c;    s++; cnt++;  }while((c) && (cnt < (max-1)));  // last byte non-zero, terminate this string  if (c) *s = 0;  return(addr);}

⌨️ 快捷键说明

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