PIC JAL Memory Routine

EEPROM 877

by M. Yalin Duyur and Vasile Surducan

procedure eeprom_877_read (byte in eeadr, byte out eedata) is
   bank_0
       asm movf eeadr,w
   bank_2
       asm movwf f877_eeadr
   bank_3
       eecon1_eepgd = off
       eecon1_rd    = on
   bank_2
       asm movf f877_eedata,w
   bank_0
       asm movwf eedata
end procedure    
 
procedure eeprom_877_write ( byte in eeadr, byte in eedata ) is
   bank_0
       asm movf eedata, w
   bank_2
       asm movwf f877_eedata 
   bank_0
       asm movf eeadr, w
   bank_2
       asm movwf f877_eeadr
   bank_3
       asm bcf f877_eecon1,eecon1_eepgd
       asm bsf f877_eecon1,eecon1_wren
       asm bcf INTCON,intcon_gie
       asm bcf INTCON,intcon_gie       
            
   assembler
      movlw 0x_55
      movwf f877_eecon2
      movlw 0x_aa
      movwf f877_eecon2
   end assembler
       asm bsf f877_eecon1,eecon1_wr
       asm bsf INTCON,intcon_gie
       asm bcf f877_eecon1,eecon1_wren
   while  eecon1_wr loop end loop 
   bank_0
end procedure