As an Amazon Associate we earn from qualifying purchases.
Chip enable error when burning a program to the AT89S52 with USBasp
I recently got a chip enable error while burning a program to an AT89S52 with a USBasp programmer. This was unexpected, because the same USBasp had already programmed ATmega8, ATtiny13 and ATmega328 chips many times without trouble.
The error means the programmer could not get the chip to enter serial programming mode. This article explains why that happens with the AT89S52, what fixed it for me, and what else to check if the error stays.
Why the error appears
The AT89S52 supports in-system programming (ISP) over an SPI-style interface. To start programming, the programmer sends a "programming enable" command and expects the chip to answer correctly. If there is no valid answer, the software reports a chip enable error (or a similar message such as "programming enable failed").
The AVR chips and the AT89S series use similar signals, but they are not identical. The most important difference is the reset pin. AVR chips are held in reset by pulling RST low. The AT89S52 uses an active-high reset, so RST must be driven high during programming. A USBasp running standard AVR firmware does not do this, so the 8051 never enters programming mode, even though the wiring looks right.
The fix: change the USBasp firmware
Remedy
When I changed the firmware of the USBasp, the problem was solved. The firmware has to be one that supports AT89S-series chips, not only AVR targets. Please note that you must use the correct fuse bits given in the read me file that comes with the firmware. Wrong fuse bits can leave the programmer’s own microcontroller unable to run or to be reprogrammed, so read that file before you start.
The two videos below show the firmware being burned to the USBasp, first with SinaProg and then with ProgISP.
Firmware burning using SinaProg
Firmware burning using ProgISP
Step-by-step procedure
- Download the firmware package from the link above and open the read me file first.
- Note the fuse bit values listed there for the USBasp’s microcontroller.
- Connect a working programmer (or a second USBasp) to the USBasp you want to update, using its ISP header.
- Open SinaProg or ProgISP, select the correct chip, and load the HEX file from the package.
- Set the fuse bits exactly as the read me file says, then write the flash.
- Disconnect, plug the updated USBasp back in, and try the AT89S52 again.
If you are not sure which programmer you have, check that your software lists the USBasp before you write anything to it.
Check the wiring to the AT89S52
Even with the right firmware, a wiring mistake gives the same error. The AT89S52 ISP connections use these pins:
- MOSI to P1.5 (pin 6 on the 40-pin DIP)
- MISO to P1.6 (pin 7)
- SCK to P1.7 (pin 8)
- RST to pin 9
- VCC to pin 40 and GND to pin 20
Compare these with the datasheet for your package, as pin numbers differ for PLCC and TQFP versions.
Other things to check if the error remains
- Crystal and capacitors. The AT89S52 needs a running clock to accept programming commands. Make sure the crystal and its two capacitors are connected to XTAL1 and XTAL2.
- Power supply. Power the chip at 5 V and share a common ground with the programmer. If the USBasp has a jumper for target power, check that it is set correctly.
- Reset circuit. A pull-down resistor on RST is normal in 8051 circuits. A capacitor or other parts on the reset line can interfere with programming, so try disconnecting them while you burn the chip.
- Loaded pins. LEDs, relays or other circuits on P1.5, P1.6 and P1.7 can disturb the signals. Disconnect them or use a bare chip on a breadboard to test.
- Programming speed. If your USBasp has a slow SCK jumper, close it and try again. A slower clock is more tolerant of long wires and weak signals.
- Cable length and contacts. Use short wires and check each connection. Loose breadboard contacts are a common cause.
- Chip itself. If everything else is correct, try another AT89S52. A damaged chip, or a chip from a different series (for example, an AT89C52, which cannot be programmed serially), will not respond.
After the chip is programmed
Once the error is gone, you can test the chip with small projects. If you are new to the 8051, try LCD interfacing with the 8051 or learn keypad interfacing in Proteus before moving to hardware. For serial communication, the UART simulation is a good next step. Simulating first helps you separate code problems from programmer problems.
If you also work with AVR boards, the same USBasp can load a bootloader, and ready-made options such as a bootloader-programmed ATmega328 save time.
More 8051 examples
You can find more AT89S52 and 8051 projects on this site, including simulations and hardware examples.
FAQ
What does "chip enable error" mean?
It means the programming software sent the programming enable command and did not get the expected reply from the chip. The cause is usually reset polarity, firmware, wiring, power or a missing clock.
Can any USBasp program an AT89S52?
Not with standard AVR firmware. You need USBasp firmware that supports AT89S-series chips, which handles the active-high reset the 8051 needs. Check the read me file that comes with it.
Why did the same USBasp work for ATmega8 and ATmega328?
Those are AVR chips, and the standard firmware is made for them. The AT89S52 uses a different reset level, so the same hardware can fail until the firmware is changed.
Do I need a crystal connected while programming?
Yes, connect the crystal and capacitors. The AT89S52 needs a clock running to respond to ISP commands, so a missing or faulty crystal can cause the same error.