I can not write and read from the EEPROM by the SPI port

Thread Starter

George.M

Joined Dec 16, 2009
1
Hello,

I have a problem reading and writing to 25C080. I tried to read and write the 25C080 eeprom with PIC18F452 but not work. So I used the next code on 25C080 but did not work. Can any one help me on what to do? Please
movlw 90h
movwf 0xF94 ; set input TRISC ( RX and SDI)
movlw 80h
movwf 0xFC7 ; SMP=1 from SSPSTAT
movlw 31h
movwf 0xFC6 ; SSPEN=1, ckp=1, FC/16 from SSPCON1

write_10
bcf 0xF83, 1 ; low chip select
movlw 01h ; write status register (WRSR)
call output
movlw 06h ; enable write operation (WREN)
call output
movlw 02h ; write data to memory .... (WRITE)
call output
movlw 00h ; write MSB address
call output
movlw 0Ah ; write LSB address
call output
movlw 33h ; write data
call output
bsf 0x F83, 1 ; high chip select
bcf 0xF83, 1 ; low chip select
movlw 04h ; disable write operation (WRDI)
call output
bsf 0xF83,1 ; high chip select
call delay ; 5ms delay
return

read_10
bcf 0xF83, 1 ; low chip select
movlw 05h ; read status register (RDSR)
call output
movlw 03h ; read data from memory (READ)
call output
movlw 00h ; read MSB address
call output
movlw 0Ah ; read LSB address
call output
movwf label ; RAM memory
bsf 0xF83,1 ; high chip select
return

output
movwf 0xFC9 ; SSPBUF register
loop
btfss 0xFC7, 0 ; test buffer full status bit
bra lop
retlw 0



Thank you
 
Top