How to use Arduino UNO to make a high voltage programmer to restore the fuse of Atmega8

Publisher:真情相伴Latest update time:2020-03-29 Source: eefocusKeywords:ArduinoUNO Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Last month, I was tinkering with the Arduino minimum system. I accidentally changed the crystal fuse position incorrectly, causing an Atmega8A-PU chip to be unrecognizable. I consulted Baidu and learned that I needed to use a high-voltage programmer to restore the fuse. Although I found ready-made flashing equipment on Taobao, I searched Baidu for relevant information and found that it should not be difficult to DIY one. Then I bought relevant electronic components from Taobao according to the circuit diagram in the information (I can't help it, it's a small place, many things can't be bought, so I can only buy them online), and made some modifications. I didn't expect that I could make it. Now I will share some of the production process. First, the finished board is as follows:




Let's talk about the production process. The entire production process mainly refers to the following relevant materials

http://jingyan.baidu.com/article/22a299b53e2ab89e19376a05.html

http://mightyohm.com/blog/2008/09/arduino-based-avr-high-voltage-programmer/  (This is a bird article page. It seems that the Baidu page above also translates the content here. You need to climb over the firewall to browse it. Why? Don’t ask me. I don’t know why technical forums also require climbing over the firewall.)

The materials for making are as follows:

1. A piece of perforated board of suitable size

2. Several 1K capacitors

3. One 2N3903 or 2N3904 transistor

4. Switch one

5. LED and other

6. One 28-pin chip holder

7. Several connecting wires

8. A 12V DC power supply device (since the high-voltage programmer requires an external 12V DC power supply, I used a boost module bought from Taobao to connect to a battery)


First, solder the electronic components to the perfboard according to the circuit diagram below.


The chip pins on the left in the picture correspond to the Arduino UNO, and the pins on the right correspond to the chip pins to be restored (i.e. the 28-pin chip socket). For the specific pin order, refer to the figure below.


After the circuit is connected, flash the recovery code into Arduino. The guy in Baidu Knowledge did not share the code file, but I found the code on that bird website. For the convenience of brothers who cannot climb over the wall, I now share the code here for your convenience.


/*  

 HVFuse - Use High Voltage Programming Mode to Set Fuses on ATmega48/88/168

 09/23/08 Jeff Keyzer http://mightyohm.com                

 The HV programming routines are based on those described in the

 ATmega48/88/168 datasheet 2545M-AVR-09/07, pg. 290-297

 This program should work for other members of the AVR family, but has only

 been verified to work with the ATmega168.  If it works for you, please

 let me know!  http://mightyohm.com/blog/contact/

 */

 

// Desired fuse configuration

#define  HFUSE  0xDF   // Default for ATmega48/88/168, for others see

#define  LFUSE  0x62   // http://www.engbedded.com/cgi-bin/fc.cgi

 

// Pin Assignments

#define  DATA    PORTD // PORTD = Arduino Digital pins 0-7

#define  DATAD   DDRD  // Data direction register for DATA port

#define  VCC     8

#define  RDY     12     // RDY/!BSY signal from target

#define  OE      11

#define  WR      10

#define  BS1     9

#define  XA0     13

#define  XA1     18    // Analog inputs 0-5 can be addressed as

#define  PAGEL   19    // digital outputs 14-19

#define  RST     14    // Output to level shifter for !RESET

#define  BS2     16

#define  XTAL1   17

 

#define  BUTTON  15    // Run button

 

void setup()  // run once, when the sketch starts

{

  // Set up control lines for HV parallel programming

  DATA = 0x00;  // Clear digital pins 0-7

  DATAD = 0xFF; // set digital pins 0-7 as outputs

  pinMode(VCC, OUTPUT);

  pinMode(RDY, INPUT);

  pinMode(OE, OUTPUT);

  pinMode(WR, OUTPUT);

  pinMode(BS1, OUTPUT);

  pinMode(XA0, OUTPUT);

  pinMode(XA1, OUTPUT);

  pinMode(PAGEL, OUTPUT);

  pinMode(RST, OUTPUT);  // signal to level shifter for +12V !RESET

  pinMode(BS2, OUTPUT);

  pinMode(XTAL1, OUTPUT);

 

  pinMode(BUTTON, INPUT);

  digitalWrite(BUTTON, HIGH);  // turn on pullup resistor

 

  // Initialize output pins as needed

  digitalWrite(RST, HIGH);  // Level shifter is inverting, this shuts off 12V

}

 

void loop()  // run over and over again

{

  while(digitalRead(BUTTON) == HIGH) {  // wait until button is pressed

  }

  // Initialize pins to enter programming mode

  digitalWrite(PAGEL, LOW);

  digitalWrite(XA1, LOW);

  digitalWrite(XA0, LOW);

  digitalWrite(BS1, LOW);

  digitalWrite(BS2, LOW);

  // Enter programming mode

  digitalWrite(VCC, HIGH);  // Apply VCC to start programming process

  digitalWrite(WR, HIGH);  // Now we can assert !OE and !WR

  digitalWrite(OE, HIGH);

  delay(1);

  digitalWrite(RST, LOW);   // Apply 12V to !RESET thru level shifter

  delay(1);

  // Now we're in programming mode until RST is set HIGH again

  

  // First we program HFUSE

  sendcmd(B01000000);  // Send command to enable fuse programming mode

  writefuse(HFUSE, true);

 

  // Now we program LFUSE

  sendcmd(B01000000);

  writefuse(LFUSE, false);

 

  delay(1000);  // wait a while to allow button to be released

 

  // Exit programming mode

  digitalWrite(RST, HIGH);

 

  // Turn off all outputs

  DATA = 0x00;

  digitalWrite(OE, LOW);

  digitalWrite(WR, LOW);

  digitalWrite(PAGEL, LOW);

  digitalWrite(XA1, LOW);

  digitalWrite(XA0, LOW);

  digitalWrite(BS1, LOW);

  digitalWrite(BS2, LOW);

  digitalWrite(VCC, LOW);

}

 

void sendcmd(byte command)  // Send command to target AVR

{

  // Set controls for command mode

  digitalWrite(XA1, HIGH);

  digitalWrite(XA0, LOW);

  digitalWrite(BS1, LOW);

  //DATA = B01000000;  // Command to load fuse bits

  DATA = command;

  digitalWrite(XTAL1, HIGH);  // pulse XTAL to send command to target

  delay(1);

  digitalWrite(XTAL1, LOW);

  //delay(1);

}

 

void writefuse(byte fuse, boolean highbyte)  // write high or low fuse to AVR

{

  // if highbyte = true, then we program HFUSE, otherwise LFUSE

  

  // Enable data loading

  digitalWrite(XA1, LOW);

  digitalWrite(XA0, HIGH);

  delay(1);

  // Write fuse

  DATA = fuse;  // set desired fuse value

  digitalWrite(XTAL1, HIGH);

  delay(1);

  digitalWrite(XTAL1, LOW);

  if(highbyte == true)

    digitalWrite(BS1, HIGH);  // program HFUSE

  else

    digitalWrite(BS1, LOW);

  digitalWrite(WR, LOW);

  delay(1);

  digitalWrite(WR, HIGH);

  delay(100);

}


The code needs to be changed according to the flash chip

#define  HFUSE  0xDF   // Default for ATmega48/88/168, for others see

#define  LFUSE  0x62   //


The above two lines are fuse bits, which need to be modified according to the restored chip. My chip is Atmega8A-PU. I found that it didn't work according to the modification in the data. I checked the fuse bits of the same model chip that can be used normally on hand. After changing it to the following content, I found that the chip was repaired normally.


#define  HFUSE  0xDC  

#define  LFUSE   0xA4


After flashing the code, connect the perforated board and 12V power supply, the L light of UNO will light up, then press the switch on the perforated board, the light of UNO will turn off and then on, the chip should have been repaired normally, if the chip is still not repaired successfully, make sure the chip is not burned, check whether the fuse position is correct. Note that this device can only restore the fuse position, and cannot repair the burned chip. Finally, remind everyone to make sure that each soldering point is in place when soldering the perforated board, otherwise you will not know what the problem is when something goes wrong.

Keywords:ArduinoUNO Reference address:How to use Arduino UNO to make a high voltage programmer to restore the fuse of Atmega8

Previous article:atmega48 spi programming code
Next article:Atmega48 eeprom debug code

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号