You are on page 1of 6

EEPROM

EEPROM RAM


..
PIC EEPROM
:
: EEDATA
. EEPROM
: EEADR EEPROM
.
: EECON1
. EEPROM
: EECON2 .
..
:
EEPROM
: . EEPROM
PIC
!.

EEADR
:
movlw 1h
movwf EEADR
! .. h


( h ) ( Fh )
.. .
EECON1 RAM
. h
EECON1
0

RD

WR

WRERR WREN

Bit
Number

EEIF

Function


PIC EEPROM
EECON1
) RD : ( ) READ ( .
EECON1 RAM
RP0 ) STATUS ( :
bsf status , RP0
RD :
bsf EECON1 , RD
RD PIC
EEADR EEPROM
EEDATA
RD .
:
bsf EECON1 , RD
EEDATA
RAM
RP0 STATUS :
bcf STATUS , RP0
movf EEDATA , W
: EEPROM
movlw 1h
movwf EEADR
bsf
STATUS , RP0

EECON1 , RD
STATUS , RP0
EEDATA , W

bsf
bcf
movf

SUBROUTINE
EEPROM W

:W
EEADR
STATUS , RP0
EECON1 , RD
STATUS , RP0
EEDATA , W

EepRead movwf
bsf
bsf
bcf
movf
return

W ..
EEPROM
PORTB :
EEADR
EepRead
PORTB
EEADR
'd'64
EEADR , W
STATUS , Z
EEloop

clrf
EEloop call
movwf
incf
movlw
xorwf
btfss
goto

EepRead ..
RP0 STATUS
' ' ..
: EEADR
EECON1 RAM
..
EepRead
RP0 :

STATUS , RP0
EEADR
STATUS , RP0
EECON1 , RD
STATUS , RP0
EEDATA , W

EepRead bcf
movwf
bsf
bsf
bcf
movf
return

RP0 ..
..
:
EEPROM

!..
EEADR
EEDATA
.. x45 ..
:
0h
EEADR
0x45
EEDATA

movlw
movwf
movlw
movwf

) ( .
PIC EEPROM
EECON1
) WT ( ) WRITE ( . WREN
) ( ) ENABLE WRITE (
.
EECON1 RAM
: h
EECON1
0

RD

WR

WRERR WREN

Bit
Number

EEIF

Function

WREN ' '


PIC . EECON1
RAM
RP0 STATUS ' ' :
bsf STATUS , RP0
WREN ': '
bsf EECON1 , WREN
PIC EEPROM

..
WREN
. EECON2 RAM
RP0 ..
0x55
EECON2
0xAA
EECON2
EECON1 , WT

movlw
movwf
movlw
movwf
bsf

WT ' ' PIC


EEADR EEPROM
EEDATA
.
PIC EEPROM
. EEPROM
RAM
.
PIC WT
' ' EEIF '. '
) ms
(
.. PIC MHz
.
) ( BYTE EEPROM

PIC
..
.. WR ' .. '
.

................. ..... .
==========================================================

.
Hossam_elkady@hotmail.com