Page 128 - Making PIC Microcontroller Instruments and Controllers
P. 128
t ta clocl(s, lilEMoFY. aND socKEts
{lflwffielg$ Prosram to read from and write to SPI SEEPRoMS loontinued)
CS vaR POREA.5 ; chip select Pin
SCR VtR PORTC.3 ; clock Pin
st vAR PoRfc.4 ; data in Pin
so vAR PoRTc.5 ; dala out Pin
ADDR VAR IIORD ; AddIESS
BO 1IAR BYTE ; dAlA
fRIAA.5 = 0 ; set cs !o ouLput
.a.DCoN1 -%00000111 ; sel all of PoRTA and PoRTE
I,ow PORIE.z ; LCD R/1,{ line 1ow (W)
PAUSE 1OO ; wait for LCD to slart uP
FOR ADDR = O TO 15 ; loop 15 tines
BO = IDDR + 100 ; B0 is data for sEEpRoM
GOEog EE9IRME ; vrile to SEEPRoM
PAUSE 10 ; delay 10 ns after each
lilEltt .ADDR
LOOP t
FOR ADDR = O IO 15 ; loop 16 lines
cosuB EEREAD ; read from SEEPRoM
"
t cDoutE $FE, I, ila.DDR, t ',jfBo ; displav
PAUSE 1000
NEKT A.DDR
GOIO rnoP
; subroutine Lo read daia fron addr in serial EEPRoM
EERETA.D: = O , enable sexial EEPROM
CS
SEIFTOIXT SI, SCK, TIISBFIRS', T$03, ADDR.BYTEI, ADDR.BYTEO]
; send read cmd and addr
SHIFIIN SOr gcR. !!SBPRE, [Eol ; Read daLa
c s = 1 ; d i s a b t e
RE{I'RN
; subr to write dala at addr
; in serial EEPROM
EEWRITE:
C g = O : e r a b _ ' s e t a E E P R O M
sgItTOrrT st. scK, lrSBFrBsI, IS061 ; send w:rite sable comnd
Cs = 1 , disable to execute comnd
c s = o ; e n a b l e
SHIFfOu! gt, sCK. !|SBFIRSI!, T$02, ADDR.BYTEI, !.DDR.BYEEO. BOl
; Sends address and dala
c s - 1 ; d i s a b t e
RETURN :
EiND ; end Program
Socket U5-Microwire Devices
Socket U5 is wired to use Microwjre memory. Figure 7.4 and Program 7.3 illustrate the
use of this memory type.