; Orange programmer module v1.12 ; (c) 2005 Alex Plusov, Valentas ; CHIP=ST95080,1K(32),ST95640.hpl ; CHIP=ST95160,2K(32),ST95640.hpl ; CHIP=ST95320,4K(32),ST95640.hpl ; CHIP=ST95640,8K(32),ST95640.hpl ; Serial SPI EEPROM with Positive Clock Strobe ;Single Supply Voltage: ;- 4.5V to 5.5V for M95xxx ;- 2.7V to 5.5V for M95xxx-V ;- 2.5V to 5.5V for M95xxx-W ;- 1.8V to 3.6V for M95xxx-R SOCKET=4 ;"SPI" PINO=SCK,0 ; Serial Clock PINO=SI,1 ; Serial Data Input PINO=CS,2 ; Chip Select PINO=WP,3 ; Write Protect PINO=HOLD,4 ; Hold PINI=SO,1 ; Serial Data Output ;Power pins: ;PINO=Vss,0,4; Ground ;PINO=Vcc,0,8; Supply Voltage CDELAY=2 ; one set delay R9=STATUS,H R10=ProtBlock,L,"None,Upper quarter,Upper half,All" [!#SETUP] R10=0 [_SEND] LOOP=(7,0){SI=R0[I],SCK=1,SCK=0} [READ] HOLD=1 WP=0 CS=1 SCK=0 CS=0 _SEND(00000011b) ;Read LOOP=(15,0){SI=ADR[I],SCK=1,SCK=0} SI=1 LOOP=(7,0){SCK=1,DATA[I]=SO,SCK=0} CS=1 [READBLOCK] HOLD=1 WP=0 CS=1 SCK=0 CS=0 _SEND(00000011b) LOOP=(15,0){SI=ADR[I],SCK=1,SCK=0} SI=1 LOOP=($BLOCKSIZE){ LOOP=(7,0){SCK=1,DATA[I]=SO,SCK=0} ADR=+1 } CS=1 [_WAITWR] ; Wait for end write memory SCK=0 LOOP=(0,1000){ CS=0 _SEND(00000101b) ; Read Status Register SI=1 R3=0 LOOP=(7,0){SCK=1,R3[I]=SO,SCK=0} CS=1 R3[0]?0{BREAK} ; WIP bit = 0 ? P=10 } ;[WRITEINIT] ;HOLD=1 ;WP=1 ;CS=1 ;SCK=0 ;CS=0 ;CONST=00000110b ; Write enable ;LOOP=CONST(7,0){SI=I,SCK=1,SCK=0} ;CS=1 ;P=20 ;CS=0 ;CONST=00000001b ;WRSR ;LOOP=CONST(7,0){SI=I,SCK=1,SCK=0} ;CONST=00000000b ;Status Register ;LOOP=CONST(7,0){SI=I,SCK=1,SCK=0} ;CS=1 ;P=5000 [WRITE] HOLD=1 WP=1 CS=1 SCK=0 CS=0 _SEND(00000110b) ; Write enable CS=1 P=20 CS=0 _SEND(00000010b) ; Write LOOP=(15,0){SI=ADR[I],SCK=1,SCK=0} LOOP=(7,0){SI=DATA[I],SCK=1,SCK=0} CS=1 _WAITWR [WRITEBLOCK] HOLD=1 WP=1 CS=1 SCK=0 CS=0 _SEND(00000110b) ; Write enable CS=1 P=20 CS=0 _SEND(00000010b) LOOP=(15,0){SI=ADR[I],SCK=1,SCK=0} LOOP=($BLOCKSIZE){ LOOP=(7,0){SI=DATA[I],SCK=1,SCK=0} ADR=+1 } CS=1 _WAITWR ["Read Status"] HOLD=1 WP=1 CS=1 SCK=0 CS=0 _SEND(00000101b) ; Read Status Register R9=0 SI=1 LOOP=(7,0){SCK=1,R9[I]=SO,SCK=0} CS=1 R10=R9,R10=/4,R10=&3 PRINT=S("Status=%02X",R9) GET=("Read Status",R10) ["Write Status"] GET=("Select protection area",R10) RA?0{EXIT} R8=R10,R8=<<2 HOLD=1 WP=1 CS=1 SCK=0 CS=0 _SEND(00000110b) ; Write enable CS=1 P=20 CS=0 _SEND(00000001b) ; Write Status Register R0=R10,R0=*4 ; shift BP bits _SEND ;R0 CS=1 P=20000 HOLD=1 WP=1 CS=1 SCK=0 CS=0 _SEND(00000101b) ; Read Status Register SI=1 LOOP=(7,0){SCK=1,R9[I]=SO,SCK=0} CS=1 P=1000 R9=&0xF VCC=0 R8?R9{PRINT=S("Status Register write OK !"),P=1000000,EXIT} R8?!R9{PRINT=E("Status Register write ERROR !")}