;-------读取EEPROM函数READEEPROM()------------- ;读取eeprom函数Readeeprom()------------- #define ReadeepromByte(ADDR,DATA) Procedure_ReadeepromByte ADDR,DATA Procedure_ReadeepromByte MACRO ADDR,DATA local start MainCbanksel = 0 ifndef Function_Readeeprom #define Function_Readeeprom Function_Readeeprom_Call_Address GOTO start Function_Readeeprom_Call_Address CBANKSEL EECON1 BCF EECON1,EEPGD;选中EEPROM BSF EECON1,RD;读EEPROM return endif start MainCbanksel = 0 ByteVal(EEADR,ADDR); ACALL Function_Readeeprom ByteVar(DATA,EEDATA); MainCbanksel = 0 ENDM
#define ReadeepromWord(ADDR,DATA) Procedure_ReadeepromWord ADDR,DATA Procedure_ReadeepromWord MACRO ADDR,DATA local start MainCbanksel = 0 ifndef Function_Readeeprom #define Function_Readeeprom Function_Readeeprom_Call_Address GOTO start Function_Readeeprom_Call_Address CBANKSEL EECON1 BCF EECON1,EEPGD;选中EEPROM BSF EECON1,RD;读EEPROM return endif start MainCbanksel = 0 ByteVal(EEADR,ADDR); ACALL Function_Readeeprom ByteVar(DATA,EEDATA); IncByte(EEADR); ACALL Function_Readeeprom ByteVar(DATA+1,EEDATA); MainCbanksel = 0 ENDM ;-------写入EEPROM函数WriteEEPROM()------------- #define WriteeepromByte(ADDR,DATA) Procedure_WriteeepromByte ADDR,DATA Procedure_WriteeepromByte MACRO ADDR,DATA local start MainCbanksel = 0 IFNDEF Function_Writeeeprom #define Function_Writeeeprom Function_Writeeeprom_Call_Addr GOTO start Function_Writeeeprom_Call_Addr CBANKSEL EECON1 BCF EECON1,EEPGD;选中EEPROM MACRO_ROMWRITE_COMMAND RETURN ENDIF start MainCbanksel = 0 ByteVal(EEADR,ADDR); ByteVar(EEDATA,DATA); ACALL Function_Writeeeprom MainCbanksel = 0 ENDM
#define WriteeepromWord(ADDR,DATA) Procedure_WriteeepromWord ADDR,DATA Procedure_WriteeepromWord MACRO ADDR,DATA local start MainCbanksel = 0 IFNDEF Function_Writeeeprom #define Function_Writeeeprom Function_Writeeeprom_Call_Addr GOTO start Function_Writeeeprom_Call_Addr CBANKSEL EECON1 BCF EECON1,EEPGD;选中EEPROM MACRO_ROMWRITE_COMMAND RETURN ENDIF start MainCbanksel = 0 ByteVal(EEADR,ADDR); ByteVar(EEDATA,DATA); ACALL Function_Writeeeprom IncByte(EEADR); ByteVar(EEDATA,DATA+1); ACALL Function_Writeeeprom MainCbanksel = 0 ENDM
;写入ROM基本硬件操作宏定义 MACRO_ROMWRITE_COMMAND MACRO CLRWDT CBANKSEL EECON1 BSF EECON1,WREN;写使能 ; BCF INTCON,GIE;关中断 MOVLW 0X55 MOVWF EECON2 MOVLW 0XAA MOVWF EECON2 BSF EECON1,WR;写允许 NOP NOP NOP BCF EECON1,WREN;写禁止 ; BSF INTCON,GIE;开中断 BTFSC EECON1,WR GOTO $-1; NOP ENDM ;-------读取Flash Rom()函数------------------- ;读取Flash Rom()函数 #define ReadFlash(ADDR,DATA) Procedure_ReadFlash ADDR,DATA #define ReadFlashWord(ADDR,DATA) Procedure_ReadFlash ADDR,DATA Procedure_ReadFlash Macro ADDR,DATA local start ifndef Function_ReadFlash #define Function_ReadFlash Function_ReadFlash_Call_Addr GOTO start Function_ReadFlash_Call_Addr ABANKSEL EECON1 BSF EECON1,EEPGD;选中Flash Rom BSF EECON1,RD;读Flash Rom return endif start GetArrayWordDByte(ADDR,EEADRH,EEADR); ACALL Function_ReadFlash SetArrayWordDByte(DATA,EEDATH,EEDATA); ENDM ;------------------- #define WriteFlash(ADDR,DATA) Procedure_WriteFlash ADDR,DATA Procedure_WriteFlash MACRO ADDR,DATA local start IFNDEF Function_WriteFlash #define Function_WriteFlash Function_WriteFlash_Call_Addr GOTO start Function_WriteFlash_Call_Addr ABANKSEL EECON1 BSF EECON1,EEPGD;选中Flash Rom MACRO_ROMWRITE_COMMAND;写入Flash基本硬件操作宏定义 RETURN ENDIF start GetArrayWordDByte(ADDR,EEADRH,EEADR); GetArrayWordDByte(DATA,EEDATH,EEDATA); ACALL Function_WriteFlash ENDM
ASM macro MainCbanksel = 0 endm ENDASM macro MainCbanksel = 0 endm |