#include <htc.h>
#if EEPROM_SIZE
unsigned char * eecpymem(unsigned char *to, unsigned char from, unsigned char size) {
unsigned char *cp = to;
EEADR = (unsigned char)from; while (WR) continue; while(size--) { #ifdef __FLASHTYPE EECON1 &= 0x7F; #endif RD = 1; *cp++ = EEDATA; ++EEADR; } return to; }
unsigned char * memcpyee(unsigned char to, const void *from, unsigned char size) { const unsigned char *ptr =from;
EEADR = (unsigned char)to; #ifdef __FLASHTYPE EECON1 &= 0x7F; #endif while(size--) { EEDATA = *ptr++; while (WR) continue; CARRY = 0; if (GIE) CARRY = 1; GIE = 0; WREN = 1; EECON2 = 0x55; EECON2 = 0xAA; WR = 1; WREN = 0; if (CARRY) GIE = 1; //an opportunity for interrupts to happen ++EEADR; } return (unsigned char *)to; }
#endif
出处:PICC的source目录 E:Program FilesHI-TECH SoftwarePICC9.50sources 现在才发现原来这里有很多代码,学习PIC不用到处找了. 相关链接:http://eesdn.cn |