; Orange programmer module v4.0 ; (c) 2001-2015 CnCLab ; Atmel AVR ;CHIP=AT90S1200,1K,90s1200.hpl ;AREA=FLASH,1K,0 ;AREA=EEPROM,64 ; Primary tested ; S1200 vs S2313: ;1. Can't answer 53h to PRG.ENABLE ;2. AVR need the SCK low and high phases to be at least 2 clock cycles long ; AT89S1200 need an SCK high phase of at least four clock cycles. ;3. As older versions of the AT90S1200 were found to react unreliably ; when a flash address is polled during programming. ;4. If chip locked - ID also not read 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 R9=Lock,L,Off,Prog,All CDELAY=10 ; 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} ; При полностью испорченном ID в режим программирования не войдет! [INIT] SCK=0 MISO=Z CFREQ=2000000 RESET=1,P=100 RESET=0,P=100000 ;min 20ms LOOP=(0,31){ ; 32 attempts R0=0xAC,_DOUT ;Programming Enable R0=0x53,_DOUT R0=0x00,_DOUT R0=0x00,_DOUT ;read device code 0 R0=0x30,_DOUT R0=0x00,_DOUT R0=0x00,_DOUT _DIN R0?0x1E{BREAK} ; Ok! ;read device code 1 R0=0x30,_DOUT R0=0x00,_DOUT R0=0x01,_DOUT _DIN R0?0x90{R0=0x1E,BREAK} ; second ID Ok! PRINT=S("Init Answer: %02lX",R0) P=200 } R0?0x01{ PRINT=A("Maybe chip Locked (Answer %02lX)\nContinue?",R0) RA?0{EXIT} R0=0x1E} R0?!0x1E{PRINT=("Chip answer error: %02lX",R0),EXIT} ;P=5 [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=20, RESET=0,P=20000 [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 R2=|R0 PRINT=("ID: %06lX",R2) [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