PICC使用__EEPROM_DATA()宏指令初始化PIC的EEPROM存储区

2019-04-15 11:56发布

PICC中使用__EEPROM_DATA()宏指令初始化EEPROM数据存储区,该指令会将写入EEPROM的数据存入HEX文件,然后写入单片机。 用法: #include "pic.h"  //包含头文件 __EEPROM_DATA(0,1,2,3,4,5,6,7); //包含8个数据(不能多也不能少) 该宏可以接受8个字节型的数据,也可以接受用单引号表示的字符,这个宏可以多次调用直到EEPROM写满为止,一般这个宏写在函数定义的外部,我一般是写在__CONFIG 之后,该宏不能在函数运行状态下调用。 PICC中的写法:

// 0x00 - 0x0f    
__EEPROM_DATA (0x55,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa);
__EEPROM_DATA (0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa);
// 0x10 - 0x1f
__EEPROM_DATA (0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa);
__EEPROM_DATA (0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa);    
// 0x20 - 0x2f
__EEPROM_DATA (0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa);
__EEPROM_DATA (0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa);        
// 0x30 - 0x3f
__EEPROM_DATA (0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa);
__EEPROM_DATA (0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa);        
// 0x40 - 0x4f
__EEPROM_DATA (0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa);
__EEPROM_DATA (0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa);        
// 0x50 - 0x5f
__EEPROM_DATA (0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa);
__EEPROM_DATA (0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa);        
// 0x60 - 0x6f
__EEPROM_DATA (0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa);
__EEPROM_DATA (0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa);            
// 0x70 - 0x7f
__EEPROM_DATA (0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
__EEPROM_DATA (0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);    
// 0x80 - 0x8f
__EEPROM_DATA (0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
__EEPROM_DATA (0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
// 0x90 - 0x9f
__EEPROM_DATA (0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
__EEPROM_DATA (0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
// 0xa0 - 0xaf
__EEPROM_DATA (0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
__EEPROM_DATA (0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
// 0xb0 - 0xbf
__EEPROM_DATA (0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
__EEPROM_DATA (0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
// 0xc0 - 0xcf
__EEPROM_DATA (0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
__EEPROM_DATA (0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
// 0xd0 - 0xdf
__EEPROM_DATA (0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
__EEPROM_DATA (0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
// 0xe0 - 0xef
__EEPROM_DATA (0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
__EEPROM_DATA (0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
// 0xf0 - 0xff
__EEPROM_DATA (0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
__EEPROM_DATA (0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);


汇编的写法:
    org    0x2100


; 0x00 - 0x0f    
    de    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
; 0x10 - 0x1f
    de    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00    
; 0x20 - 0x2f
    de    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00    
; 0x30 - 0x3f
    de    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00    
; 0x40 - 0x4f
    de    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00    
; 0x50 - 0x5f
    de    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00    
; 0x60 - 0x6f
    de    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00    
; 0x70 - 0x7f
    de    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
; 0x80 - 0x8f
    de    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
; 0x90 - 0x9f
    de    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
; 0xa0 - 0xaf
    de    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
; 0xb0 - 0xbf
    de    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
; 0xc0 - 0xcf
    de    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
; 0xd0 - 0xdf
    de    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
; 0xe0 - 0xef
    de    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
; 0xf0 - 0xff
    de    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00