Full Version : ATtiny12 Fuse Restorer (ASM)
avr >>TECHNICAL & HARDWARE >>ATtiny12 Fuse Restorer (ASM)


AVR_Admin- 04-28-2006
Dick Cappel's ATtiny12 Fuse Restorer


This restores the fuses in an ATtiny12 via High Voltage Serial Programming.

Plug an ATtiny12 into the 8 pin socket and hold down "GO!" button. The LED will come on at the end of the programming process, which only takes a couple hundred millisecond. The fuses are now restored to their factory default states. This picture was taken before the voltage doubler, made with the 1N916 and 100 uf capacitor were added.

The Circuit

For the details of the programming algorithm, see the Atmel ATtiny12 data sheet. All of the necessary signals are generated by the AT90S1200A . which is clocked by its internal oscillator. If you wan to use an AT90S1200 (non-A) you will have to add a crystal or ceramic resonator and load capacitors. The +12v programming voltage is developed in the switched analog regulator made up of the 2N2907 and the 2N4401 that serves as the error amplifier. +17 Volts to supply the switched analog regulator is generated from a 9 volt power supply, in my case, a 8.4 volt Ni-MH transistor radio battery. The 100 uF capacitor charges to the battery voltage through the 1N916 and the internal circuitry inside the 7805. If you have any doubt the capacitor will charge fully, you can place a 1K resistor from the regulator's input to ground. When the "Go" button is pressed the charged 100 uf capacitor is placed in series with the 9v battery supply and the battery is applied to the 7805, thus providing +5V to the logic and +17 volts to the switched 12V supply simultaneously. Since the +12v is only on for a few milliseconds, the voltage on the capacitor does not droop enough during the programming period for the switched 12 volt regulator to go out of regulation.

The second 2N4401 -the one with the emitter grounded is only there to make sure that pin 1 of the ATtiny12 is pulled to ground when its supposed to be grounded. Note that D9 is set up with a weak pull-up of about 100 uA so that a base resistor is not needed in series with the 2N4401 base. I didn't use a 2N2907 as the PNP in the circuit I built because I have a bunch of similar transistors with a strange part number (if you have a data sheet for a 2NSA1020Y please contact me) so this aspect has not truly been tested, though the circuit was designed for a 2N2907.

ADJUST THE REGULATOR BEFORE YOU PLUG IN THE AT90S1200 OR THE ATtiny12.

Adjustment procedure:


1. The AT90S1200 and ATtiny12 sockets must be empy for this procedure. If there are parts in these scokets, remove them before startring this procedure.


2. Temporarily but securely jumper the "Go" button. (Do not try just holding it with your finger because to open and close the button during the procedure might cause excessive voltage to appear in the circuit.


3. Temporarily but securely jumper Pin 11 of the AT90S1200 socket to Pin 20 of the AT90S1200 socket (this puts + 5 volts on the base of the NPN transistor..


4. Apply between +15 and + 20 volts DC to the input of the circuit, by using a bench supply or two 9 volt transistor radio batteries in series.


5. Adjust he 10K pot to obtain + 12 volts DC on pin 1 of the ATtiny12 socket.


6. Seal the pot with fingernail polish or glue.


7. Remove the +15 to + 20 volt power supply.


8. Remove the jumper from Pin 11 of the AT90S1200 socket to pin 20 of the AT90S1200 socket.


9. Remove the jumper across the "GO" button.

My sincere thanks go to Pablo Miguel for finding and helping to correct errors in the above adjustment procedure.


Firmware

The firmware reprograms the fuses to the factory default values using the High Voltage Serial Programming Algorithim described in the ATtiny11/12 datasheet.

My thanks go to Peter Dannegger for clearing up an ambiguity in the data sheet.

Other notes

This device does not verify that the fuses have been reset, so this would be a nice feature (if you add this, please send me a copy of the code). This circuit has a potential reliability risk in that there is a .001 uf capacitor from D4 to ground. Under some situation, such as when the capacitor is being repeatedly charged and discharged by the output pin, I would be concerned with metal migration and would then change the circuit to drive a switching device to control the power to the ATtiny12 socket. Since it will probably take tens of thousands of pulses before I have a problem, and the handmade board is likely to fall apart long before the output pin fails, I decided its a shortcut I can take for a device built for my personal use. In most circumstances it would be unwise to take this shortcut on a commercial product.

Link to Site: http://cappels.org/dproj/t12fp/t12f.htm


AVR_Admin- 04-28-2006
CODE


;*********************************
;AT90S1200 program to restore fuses on ATtiny12 to factory defaults.
;;*********************************
 
;This has successfully restored the RESET ENABLE, SPI DISABLE, INTERNAL CLOCK, and SECUIRTY MODE 1 fuses.
 
 
.include "1200def.inc"    
.list
 
.def temp =r16
.def tmult =r17
 
 
; AT90S1200 specific information and definitions
 
 
;PORTB assignments
.equ LED =0;B0  High to light LED
 
;PORTD assignments
;Pins on PORTD correspond to pins on target PORTB
.equ sin  = 0;D0 Serial data in to target
.equ sinst  = 1;D1 Serail instructions in to target
.equ dout = 2;D2 Data out from target
.equ clk = 3;D3 Clock in to targtet
.equ vcc = 4;D4 VCC to target
.equ nreset = 5;D5 Ground reset pin (PB5) on target
.equ plus12 = 6;D6 +12V to target reset pin (PB5)
 
;Note that PD5 is kept as an input and weak pullups are switched to
; switch the grounded emitter transistor connected to its output.
 
.cseg
 
.ORG $0000

;.ORG $0002
; rjmp timerservice
 
start:
 
ldi tmult,$0
startdelay:
ldi temp,$0
tloop:
dec temp
brne tloop
dec tmult
brne tloop
 
ldi temp,$5B ;Setup PORTD data
out DDRD,temp
 
ldi temp,$20 ;Setup DDRD
out PORTD,temp
 
ldi temp,$00 ;Set up PORTB data all zeros
out PORTB,temp

ldi temp,$FF ;Set up DDRB
out DDRB,temp
 
 
 
rcall shortdelay

sbi PORTD,vcc ;Apply VCC to target

rcall shortdelay
 
 
ldi temp,$10;Toggle Bit 3 16 times
toggle3:

rcall clockit
dec temp
brne toggle3

rcall shortdelay

ldi temp,$50;Apply +12V to target
out PORTD,temp

rcall  shortdelay
 
 

  ;Shift out data

;coded as PD0 as lsb and PD1 as msb

 
;Instruction 1
rcall p0
rcall p0
rcall p3
rcall p0
rcall p0
rcall p2
rcall p2
rcall p0
rcall p0
rcall p0
rcall p0
 

;Instruction 2
rcall p0
rcall p0
rcall p1
rcall p2
rcall p1
rcall p2
rcall p2
rcall p1
rcall p0
rcall p0
rcall p0
 
;Instruction 3
rcall p0
rcall p0
rcall p2
rcall p2
rcall p0
rcall p0
rcall p2
rcall p0
rcall p0
rcall p0
rcall p0
 
 
;Intsruction 4
rcall p0
rcall p0
rcall p2
rcall p2
rcall p0
rcall p2
rcall p2
rcall p0
rcall p0
rcall p0
rcall p0

;STOP AND SHUT DOWN

ldi temp,$40
out PORTD,temp
rcall shortdelay
ldi temp,$00
out PORTD,temp

finished:
sbi PORTB,LED ;Light the LED on PB0
rjmp finished;320 us



p0:
cbi PORTD,sinst;PD1
cbi PORTD,sin;PD0
rcall clockit
ret

 
p1:
cbi PORTD,sinst;PD1
sbi PORTD,sin;PD0
rcall clockit
ret

p2:
sbi PORTD,sinst;PD1
cbi PORTD,sin;PD0
rcall clockit
ret

 

p3:
sbi PORTD,sinst;PD1
sbi PORTD,sin;PD0
rcall clockit
ret
   
 
clockit:
sbi PORTD,clk
cbi PORTD,clk
ret

 
shortdelay:;16 cycle delay routine (about 13 us at 4 MHz)
ldi temp,$10
stilldelaying:
dec temp
brne stilldelaying
ret  



Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.