Hi Leon, you wrote:- >Wanting to use the 16C84 EEPROM data memory, I inserted the following --Snip-- >After running the program, I put the chip into my programmer and read >the program and EEPROM data memory into the buffers, but the EEPROM data >has not changed. Can someone please tell me what I am doing wrong? > >Leon >-- >Leon Heller, G1HSM | "Do not adjust your mind, there is >E-mail leon@lfheller.demon.co.uk | a fault in reality": on a wall >Phone: +44 (0)1734 471424 | many years ago in Oxford. Here is some code taken directly from a working program I wrote. It is written in Parallax Assembler (PASMX) but you should get the idea. This is a clip of the list output from the assembler and the first column is line numbers followed by the assembler code words. You can see from this which PASMX instructions map to multiple Mchip instructions. In the great traddition of these things, the simpler lower level routines are listed first. (n.b. :loop is a local label) Sorry I didn't have time to translate it for you. I hope it is of some help. (Contact me direct if there is anything else you need help with Leon - remember the transputer and QL? - long time no see!) All the best. Dave. 1060 ;Routine to write a byte to the EEPROM, assumes EEADR and EEDATA have 1061 ;already been loaded with the required values and EEwrenable has already 1062 ;been called to prime the safety lockout mechanism. 1063 031D- 138B EEwriteit clrb GIE ;must run with interrupts disabled 1064 031E- 1683 setb RP0 ;these registers are in page 1 1065 031F- 3055 0089 mov EECON2,#55h ;Required sequence to activate write 1066 0321- 30AA 0089 mov EECON2,#0AAh ;55, AA, set WR. 1067 0323- 1488 setb WR 1068 0324- 1E08 2B24 :loop jnb EEIF,:loop ;wait until write is complete 1069 0326- 1108 clrb WREN ;safe once again ! 1070 0327- 1208 clrb EEIF ;reset indicator for next time. 1071 0328- 1283 clrb RP0 1072 0329- 0009 reti ;reenable interrupts when all done 1073 1074 032A- 1683 EEread setb RP0 ;control register is in Page 1. 1075 032B- 1408 setb RD ;initiate read operation 1076 032C- 1283 clrb RP0 1077 032D- 0008 ret 1078 1079 032E- 1683 EEwrenable setb RP0 ;EEPROM write enable safety guard 1080 032F- 1508 setb WREN 1081 0330- 1283 clrb RP0 1082 0331- 0008 ret 1083 1084 0332- 232E EEwrite call EEwrenable 1085 0333- 231D call EEwriteit 1086 0334- 0008 ret 1087 1088 ;Get EEPROM data into RAM 1089 ;Enter with R1=source, W=destination, R2=number of bytes to move 1090 0335- 0084 EEget mov FSR,W ;start addr of target regs. 1091 0336- 0826 0089 :loop mov EEADR,R1 ;point to byte to retrieve 1092 0338- 232A call EEread ;select read mode 1093 0339- 0808 0080 mov INDIRECT,EEDATA ;load non-volatile value to working reg 1094 033B- 0A84 inc FSR ;next indirect address 1095 033C- 0AA6 inc R1 1096 033D- 0BA7 2B36 djnz R2,:loop 1097 033F- 0008 ret 1098 1099 ;Put RAM data into the EEPROM. 1100 ;Enter with R1=destination, W=sorce, R2=number of bytes to move. 1101 0340- 0084 EEput mov FSR,W 1102 0341- 0826 0089 :loop mov EEADR,R1 ;point to byte to store 1103 0343- 0800 0088 mov EEDATA,INDIRECT ;load ram value to EE reg 1104 0345- 2332 call EEwrite 1105 0346- 0A84 inc FSR ;next indirect sorce address 1106 0347- 0AA6 inc R1 ;next destination address 1107 0348- 0BA7 2B41 djnz R2,:loop 1108 034A- 0008 ret