Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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

Status
Not open for further replies.

George.M

New Member
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
 

Pommie

Well-Known Member
Most Helpful Member
If you want any help then you need to rewrite your code using the supplied names.

So,
Code:
movlw 90h
movwf 0xF94 ; set input TRISC ( RX and SDI)
Becomes,
Code:
    movlw  90h
    movwf TRISC ; set input TRISC ( RX and SDI)
As there is no way I'm checking if you have managed to get all the addresses right.

You may find that when you use the supplied names that it works.

Mike.
 

George.M

New Member
Can you give me a asm code (write/read) for 25XXX eeprom please?
I want to check with my asm code.

Thank you
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Top