Tony, THANK YOU, it is now working fine, you should send your examples to Microchip so that it can be printed as real working code! Thanks again Chris ----- Original Message ----- From: "Tony Nixon" To: Sent: Tuesday, August 14, 2001 5:48 PM Subject: Re: [PIC]:trouble writing to eeprom on 16f628 > PD wrote: > > > > Has anyone seen any examples that shows a routine to write multiple ram locations to the eeprom, it would help me greatly. > > > This may help... > > > ; WRITE EEPROM EXAMPLE > > movlw 0x00 ; set EEPROM address = 0 > bsf STATUS,RP0 ; RAM Page 1 > movwf EEADR > movlw 0x22 > call WrtEep ; write 0x22 to EEPROM address 0h > > movlw 0x33 > call WrtEep ; write 0x33 to EEPROM address 1h > > .... > > ; READ EEPROM EXAMPLE > > movlw 0x00 ; set EEPROM address = 0 > bsf STATUS,RP0 > movwf EEADR > bcf STATUS,RP0 > call RdEep ; read EEPROM address 0x00 = 0x22 > movwf Temp1 > > call RdEep ; read EEPROM address 0x01 = 0x33 > movwf Temp2 > > .... > > ; > ; ----------------------------- > ; WRITE AN INTERNAL EEPROM BYTE > ; ----------------------------- > ; EEADRH/EEADR set before entry > ; Data to store is in W on entry > ; > WrtEep bsf STATUS,RP0 ; RAM Page 1 > movwf EEDATA > bsf EECON1,WREN > movlw 55h > movwf EECON2 > movlw 0xAA > movwf EECON2 > bsf EECON1,WR > WrtLoop nop > btfsc EECON1,WR > goto WrtLoop > > incf EEADR ; automatic EEADR increment > bcf EECON1,WREN > bcf STATUS,RP0 ; RAM Page 0 > return > ; > ; ---------------------------- > ; READ AN INTERNAL EEPROM BYTE > ; ---------------------------- > ; Result is in W > ; > RdEep bsf STATUS,RP0 ; RAM Page 1 > bsf EECON1,RD ; read back ROM location > nop ; in case internal ROM reading > nop > incf EEADR ; automatic EEADR increment > movf EEDATA,W > bcf STATUS,RP0 ; RAM Page 0 > return > > -- > Best regards > > Tony > > mICros > http://www.bubblesoftonline.com > mailto:sales@bubblesoftonline.com > > -- > http://www.piclist.com hint: To leave the PICList > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > > > -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu