;***************************** Librería "EEPROM.INC" **********************************;; ====================================================================; Del libro "MICROCONTROLADOR PIC16F84. DESARROLLO DE PROYECTOS".; E. Palacios, F. Remiro y L. López. www.pic16f84a.com; Editorial Ra-Ma. www.ra-ma.es; ====================================================================;; Estas subrutinas permiten realizar las tareas básicas de escritura y lectura de la; memoria EEPROM de datos del PIC.;; Subrutina "EEPROM_LeeDato" ------------------------------------------------------------;; El microcontrolador lee el dato que hay escrito en la posición de la EEPROM del PIC apuntada; por el contenido del registro de trabajo W. El resultado se proporciona en el mismo W.;; Entrada: En (W) la dirección de la memoria EEPROM a leer.; Salida : En (W) el byte leído.EEPROM_LeeDato bcf STATUS,RP0 ; Asegura que trabaja con el Banco 0. movwf EEADR ; Dirección a leer. bsf STATUS,RP0 ; Banco 1. bsf EECON1,RD ; Orden de lectura.EEPROM_SigueLeyendo btfsc EECON1,RD ; El PIC indica que ha terminado la lectura goto EEPROM_SigueLeyendo ; poniendo en bajo este bit. bcf STATUS,RP0 ; Banco 0. movf EEDATA,W ; El byte leído al registro W. return; Subrutina "EEPROM_EscribeDato" --------------------------------------------------------;; Escribe el dato introducido en el registro de trabajo W en la posición de memoria EEPROM del; PIC apuntada por el registro EEADR.;; Como altera el valor del registro INTCON al posicionar el flag GIE, éste se debe guardar al; principio de la subrutina y restaurarlo al final.;; Entradas: En el registro EEADR la dirección de la memoria EEPROM a escribir.; En el registro W el byte a escribir.; CBLOCK EEPROM_GuardaINTCON ENDCEEPROM_EscribeDato bcf STATUS,RP0 ; Asegura que trabaja con el Banco 0. movwf EEDATA ; El byte a escribir. movf INTCON,W ; Reserva el valor anterior de INTCON movwf EEPROM_GuardaINTCON bsf STATUS,RP0 ; Acceso al Banco 1. bcf INTCON,GIE ; Deshabilita todas las interrupciones. bsf EECON1,WREN ; Habilita escritura.;; El fabricante especifica que hay que seguir esta secuencia para escritura en EEPROM:; movlw 0x55 movwf EECON2 movlw 0xAA movwf EECON2 bsf EECON1,WR ; Inicia la escritura.EEPROM_TerminaEscribir btfsc EECON1,WR ; Comprueba que termina de escribir en la EEPROM. goto EEPROM_TerminaEscribir bcf EECON1,WREN ; Desautoriza la escritura en EEPROM. bcf EECON1,EEIF ; Limpia este flag. bcf STATUS,RP0 ; Acceso al Banco 0. movf EEPROM_GuardaINTCON,W ; Restaura el valor anterior de INTCON. movwf INTCON return; ====================================================================; Del libro "MICROCONTROLADOR PIC16F84. DESARROLLO DE PROYECTOS".; E. Palacios, F. Remiro y L. López. www.pic16f84a.com; Editorial Ra-Ma. www.ra-ma.es; ====================================================================
;***************************** Librería "EEPROM_16F88.INC";;; Estas subrutinas permiten realizar las tareas básicas de escritura y lectura de la; memoria EEPROM de datos del PIC.;; Subrutina "EEPROM_LeeDato" ------------------------------------------------------------;; El microcontrolador lee el dato que hay escrito en la posición de la EEPROM del PIC apuntada; por el contenido del registro de trabajo W. El resultado se proporciona en el mismo W.;; Entrada: En (W) la dirección de la memoria EEPROM a leer.; Salida : En (W) el byte leído.EEPROM_LeeDato bsf STATUS,RP1 ; Asegura que trabaja con el Banco 2. bcf STATUS,RP0 movwf EEADR ; Dirección a leer. bsf STATUS,RP1 ; Banco 3. bsf STATUS,RP0 bsf EECON1,RD ; Orden de lectura.EEPROM_SigueLeyendo btfsc EECON1,RD ; El PIC indica que ha terminado la lectura goto EEPROM_SigueLeyendo ; poniendo en bajo este bit. bsf STATUS,RP1 ; Banco 2. bcf STATUS,RP0 movf EEDATA,W ; El byte leído al registro W. return; Subrutina "EEPROM_EscribeDato" --------------------------------------------------------;; Escribe el dato introducido en el registro de trabajo W en la posición de memoria EEPROM del; PIC apuntada por el registro EEADR.;; Como altera el valor del registro INTCON al posicionar el flag GIE, éste se debe guardar al; principio de la subrutina y restaurarlo al final.;; Entradas: En el registro EEADR la dirección de la memoria EEPROM a escribir.; En el registro W el byte a escribir.;;-------------------------------+; Bancos de memoria 16F88 |; |; RP1:PP0 Banco |; 0 0 0 |; 0 1 1 |; 1 0 2 |; 1 1 3 |; |;-------------------------------+ CBLOCK EEPROM_GuardaINTCON ENDCEEPROM_EscribeDato bsf STATUS,RP1 bcf STATUS,RP0 ; Asegura que trabaja con el Banco 2. movwf EEDATA ; El byte a escribir. movf INTCON,W ; Reserva el valor anterior de INTCON movwf EEPROM_GuardaINTCON bsf STATUS,RP1 ; Acceso al Banco 3. bsf STATUS,RP0 bcf INTCON,GIE ; Deshabilita todas las interrupciones. bsf EECON1,WREN ; Habilita escritura.;; El fabricante especifica que hay que seguir esta secuencia para escritura en EEPROM:; movlw 0x55 movwf EECON2 movlw 0xAA movwf EECON2 bsf EECON1,WR ; Inicia la escritura.EEPROM_TerminaEscribir btfsc EECON1,WR ; Comprueba que termina de escribir en la EEPROM. goto EEPROM_TerminaEscribir bcf EECON1,WREN ; Desautoriza la escritura en EEPROM. bcf EECON1,EEIF ; Limpia este flag. bsf STATUS,RP1 ; Acceso al Banco 2. bcf STATUS,RP0 movf EEPROM_GuardaINTCON,W ; Restaura el valor anterior de INTCON. movwf INTCON return
----------------------------------------------------------------------Clean: Deleting intermediary and output files.Clean: Done.Executing: "C:\Archivos de programa\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F88 "RS232_11_16F88.asm" /l"RS232_11_16F88.lst" /e"RS232_11_16F88.err" /d__DEBUG=1Message[302] H:\PIC16F84A\16F88\RS232_11_16F88.ASM 52 : Register in operand not in bank 0. Ensure that bank bits are correct.Message[302] H:\PIC16F84A\16F88\RS232_11_16F88.ASM 215 : Register in operand not in bank 0. Ensure that bank bits are correct.Message[302] H:\PIC16F84A\16F88\LCD_4BIT.INC 96 : Register in operand not in bank 0. Ensure that bank bits are correct.Message[302] H:\PIC16F84A\16F88\LCD_4BIT.INC 110 : Register in operand not in bank 0. Ensure that bank bits are correct.Message[302] H:\PIC16F84A\16F88\EEPROM.INC 23 : Register in operand not in bank 0. Ensure that bank bits are correct.Message[302] H:\PIC16F84A\16F88\EEPROM.INC 26 : Register in operand not in bank 0. Ensure that bank bits are correct.Message[302] H:\PIC16F84A\16F88\EEPROM.INC 28 : Register in operand not in bank 0. Ensure that bank bits are correct.Message[302] H:\PIC16F84A\16F88\EEPROM.INC 32 : Register in operand not in bank 0. Ensure that bank bits are correct.Message[302] H:\PIC16F84A\16F88\EEPROM.INC 64 : Register in operand not in bank 0. Ensure that bank bits are correct.Message[302] H:\PIC16F84A\16F88\EEPROM.INC 70 : Register in operand not in bank 0. Ensure that bank bits are correct.Message[302] H:\PIC16F84A\16F88\EEPROM.INC 75 : Register in operand not in bank 0. Ensure that bank bits are correct.Message[302] H:\PIC16F84A\16F88\EEPROM.INC 77 : Register in operand not in bank 0. Ensure that bank bits are correct.Message[302] H:\PIC16F84A\16F88\EEPROM.INC 78 : Register in operand not in bank 0. Ensure that bank bits are correct.Message[302] H:\PIC16F84A\16F88\EEPROM.INC 80 : Register in operand not in bank 0. Ensure that bank bits are correct.Message[302] H:\PIC16F84A\16F88\EEPROM.INC 82 : Register in operand not in bank 0. Ensure that bank bits are correct.Message[302] H:\PIC16F84A\16F88\EEPROM.INC 83 : Register in operand not in bank 0. Ensure that bank bits are correct.Executing: "C:\Archivos de programa\Microchip\MPASM Suite\mplink.exe" /p16F88 "RS232_11_16F88.o" /u_DEBUG /z__MPLAB_BUILD=1 /z__MPLAB_DEBUG=1 /o"RS232_11_16F88.cof" /M"RS232_11_16F88.map" /W /xMPLINK 4.35, LinkerCopyright (c) 2009 Microchip Technology Inc.Errors : 0Loaded H:\PIC16F84A\16F88\RS232_11_16F88.cof.----------------------------------------------------------------------Debug build of project `H:\PIC16F84A\16F88\PicRS232_16F88.mcp' succeeded.Language tool versions: MPASMWIN.exe v5.35, mplink.exe v4.35Preprocessor symbol `__DEBUG' is defined.Thu Dec 31 20:21:43 2009----------------------------------------------------------------------BUILD SUCCEEDED
; Leer EEPROM.EEPROM_LeeDato BANKSEL EEADR ; Select Bank of EEADR MOVF ADDR, W ; MOVWF EEADR ; Data Memory Address ; to read BANKSEL EECON1 ; Select Bank of EECON1 BCF EECON1, EEPGD; Point to Data memory BSF EECON1, RD ; EE Read BANKSEL EEDATA ; Select Bank of EEDATA MOVF EEDATA, W ; W = EEDATA return; Escribir EEPROM. CBLOCK EEPROM_GuardaINTCON ENDCEEPROM_EscribeDato BANKSEL EECON1 ; Select Bank of ; EECON1 BTFSC EECON1, WR ; Wait for write GOTO $-1 ; to complete BANKSEL EEADR ; Select Bank of ; EEADR MOVF ADDR, W ; MOVWF EEADR ; Data Memory ; Address to write MOVF VALUE, W ; MOVWF EEDATA ; Data Memory Value ; to write BANKSEL EECON1 ; Select Bank of ; EECON1 BCF EECON1, EEPGD ; Point to DATA ; memory BSF EECON1, WREN ; Enable writes BCF INTCON, GIE ; Disable INTs. MOVLW 55h ; MOVWF EECON2 ; Write 55h MOVLW AAh ; MOVWF EECON2 ; Write AAh BSF EECON1, WR ; Set WR bit to ; begin write BSF INTCON, GIE ; Enable INTs. BCF EECON1, WREN ; Disable writes