; Orange programmer module v4.0 ; (c) 2001-2012 CnCLab ; Atmel AVR ; CHIP=AT90S2313,2K ; FLASH+EEPROM ; Primary tested ALLPINS=20 INFO="AVR Adapter" OPTIONS=f, PINO=SCK, 0,19 PINO=MOSI, 2,17 PINO=MISO, 1,18 PINO=RESET,3,1 PINI=MISO, 1,18 PING=GND,255,10 PINO=VCC,254,20 BUSO=CFREQ,128 ;P12 out R9=Lock,L,Off,Prog,All CDELAY=4 ; minimum periods for the serial clock (SCK) > 4 XTAL1 clock cycle! [_DOUT] R1=0; LOOP=(7,0){MOSI=R0[I],SCK=1,R1[I]=MISO,SCK=0} [_DIN] R0=0 LOOP=(7,0){SCK=1,R0[I]=MISO,SCK=0} ;return R0 [_RDLOCK] _DOUT(0x58) ;rd lock bits _DOUT(0x00) _DOUT(0x00) _DIN [INIT] ;EO=0,P=10 ;BB on SCK=0 MISO=Z CFREQ=2000000 RESET=1,P=500 RESET=0,P=100000 LOOP=(0,31){ ; 32 attempts _DOUT(0xAC) ;Programming Enable _DOUT(0x53) _DOUT(0x00) R3=R1 R0=0x00,_DOUT R3?0x53{BREAK} SCK=1,SCK=0 } R3?!0x53{PRINT=("ANSWER ERROR: %02lX",R1),EXIT} P=10 [READ] $AREA?0{ R0=0x20 ;program memory area R1=ADR,R0[3]=R1[0] ;Hi/Lo _DOUT LOOP=(16,9){MOSI=ADR[I],SCK=1,SCK=0} LOOP=(8,1){MOSI=ADR[I],SCK=1,SCK=0} } $AREA?1{ R0=0xA0 ;eeprom area _DOUT LOOP=(15,8){MOSI=ADR[I],SCK=1,SCK=0} LOOP=(7,0){MOSI=ADR[I],SCK=1,SCK=0} } _DIN ;common DATA=R0 [WRITE] $AREA?0{ R0=0x40 ;program memory R1=ADR,R0[3]=R1[0] ;Hi/Lo _DOUT LOOP=(16,9){MOSI=ADR[I],SCK=1,SCK=0} LOOP=(8,1){MOSI=ADR[I],SCK=1,SCK=0} R0=DATA,_DOUT P=4000 ; 4ms } $AREA?1{ R0=0xC0 ;eeprom memory area _DOUT LOOP=(15,8){MOSI=ADR[I],SCK=1,SCK=0} LOOP=(7,0){MOSI=ADR[I],SCK=1,SCK=0} R0=DATA,_DOUT P=4000 ; 4ms } [WRITEEND] P=10000 RESET=1,P=200 RESET=0,P=10000 ; При установленной защите не читает ID! [READID] R0=0x30,_DOUT R0=0x00,_DOUT R0=0x00,_DOUT _DIN R2=R0,R2=<<8 R0=0x30,_DOUT R0=0x00,_DOUT R0=0x01,_DOUT _DIN R2=|R0,R2=<<8 R0=0x30,_DOUT R0=0x00,_DOUT R0=0x02,_DOUT _DIN R0=|R2 PRINT=S("ID: %06lX",R0) [Erase] R0=0xAC,_DOUT ;Chip Erase R0=0x80,_DOUT R0=0x00,_DOUT R0=0x00,_DOUT P=10000 RESET=1,P=20 RESET=0,P=20000 [Lock] R9=2 GET=("Write Lock Bits",R9) RA?0{EXIT} R0=0xAC,_DOUT ;Write lock bits R0=0xE0 R9?0{R0=0xE6} R9?1{R0=0xE4} R9?2{R0=0xE0} _DOUT R0=0x00,_DOUT R0=0x00,_DOUT P=10000 RESET=1,P=20, RESET=0,P=20000 [END] RESET=1 ;EO=1,P=10 ;BB off