Hi Royce: I'm attaching some code for the 12F675 that reads and writes the EEPROM. The big problem I had was keeping track of Bank 1 and Bank 0 registers. It sure would help if MC labeled "Bank 0" or "Bank 1" when they show the register in the manual. LOC OBJECT CODE LINE SOURCE TEXT VALUE 00858 page 00859 ;================= Data EEPROM Subs =================== 00860 ; Enter with W set to the data EEPROM address to write 00861 ; and EE_data will be written 00862 ; ADD verify read and test to be sure <- on "to do list" 00863 cblock 0000003D 00864 EE_data 00865 endc 01C8 00866 WEE 00867 ; ----- Write 1 Byte into Data EEPROM ---- 00868 ; Only one byte should be written in each pass through the ISR 00869 ; because the ISR runs about once every 10 ms and the max time 00870 ; for a byte write is 8 ms 00871 ; 01C8 138C 00872 BCF PIR1, EEIF 01C9 1683 00873 BSF STATUS, RP0 ; bank 1 01CA 009B 00874 MOVWF EEADR 01CB 083D 00875 MOVF EE_data,W ; Data 01CC 009A 00876 MOVWF EEDATA 00877 01CD 151C 00878 BSF EECON1, WREN ; enable write EEPROM 01CE 3055 00879 MOVLW h'55' ; Unlock Write 01CF 009D 00880 MOVWF EECON2 01D0 30AA 00881 MOVLW h'AA' 01D1 009D 00882 MOVWF EECON2 01D2 149C 00883 BSF EECON1,WR 01D3 189C 00884 waitEE BTFSC EECON1, WR 01D4 29D3 00885 GOTO waitEE 00886 ; ---- done byte write ------- 01D5 138C 00887 BCF PIR1, EEIF 01D6 1283 00888 BCF STATUS, RP0 ; Bank 0 01D7 0008 00889 RETURN 00890 00891 ;-------------------------------------- 00892 01D8 00893 REE 00894 ; --------- Read 1 Byte from Data EEPROM ------- 00895 ; enter with W pointing to EEPROM address 00 -> 7F 00896 ; exit with data in W WORKING 4 Dec 2002 00897 ; note this takes only 6 instruction times, no delays 00898 ; like for writing 01D8 1683 00899 BSF STATUS, RP0 ; Bank 1 01D9 009B 00900 MOVWF EEADR ; setup address to read 01DA 141C 00901 BSF EECON1,RD ; read it 01DB 081A 00902 MOVF EEDATA,W ; put data into W 01DC 1283 00903 BCF STATUS, RP0 ; Bank 0 01DD 0008 00904 RETURN 00905 ;========================================================== Have Fun, Brooke > Date: Fri, 20 Dec 2002 11:50:59 -0500 > From: Royce Simmons > Subject: [PIC] EEPROM Write > > Greetings All, > > Attached is a failed effort to write to the internal EEPROM of a 16F628. > All I get is zeros in the EEPROM. I hope > someone can show me the eror of my ways. > > I can read the EEPROM. The code came from the 16F628 manual, page 93. I > added code to increment the address and the data byte and loop until the > memoey is full. > > Happy holidays, > > Royce -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body