Programming AT89S5x chips with USBasp

In older electronic equipment that has been withdrawn from use, you can find interesting elements, including various types of microcontrollers.
Although nowadays 32-bit microcontrollers with high computing power and network interfaces are easily available for a small amount of money, sometimes an older 8-bit chip, obtained, for example, from a device intended for disposal, may be enough to implement the project.
Particularly interesting are the 89S5x chips from Atmel. These are devices belonging to the 8051 family, equipped with an ISP interface (the letter S in the designation), which today is nothing unusual and even a norm, however, it should be remembered that other devices from this family could only be programmed in parallel (e.g. AT89C51 , not to mention non-flash versions).
I was starting to design a DCF77 clock with a programmable controller function and I was looking for a suitable processor.
Since I have several 89S52 systems from disassembly in my collection, I decided to use them for this purpose. In order for the development process to run in accordance with current standards, of course I wanted to use ISP for programming. It turned out, however, that all AVR programmers that I have are not able to communicate with the 89S52 in a serial way.

A short web search led me to the USBasp project: https://www.fischl.de/usbasp. Within a few hours, a prototype with ATmega8 was created, mounted on a universal board. The launch went without a problem, the avrdude program detected the programmer.
Unfortunately, when trying to read the content of 89S52, I got the following message:
Code: Bash
Something was wrong with the communication on the USBasp - AT89S52 line.
Debugging with an oscilloscope and searching the web yielded the answer. The problem was that USBasp had a hardcoded procedure for setting the RESET pin on the ISP interface. The AVR chips have a negated RESET input, while the 89S5x chips have a non-negated input. In other words, the RESET active state for AVR is low, for 89S5x it is high.
The author of USBasp has placed sources on his website where you can find the reason for this state of affairs:
[syntax=c]void ispConnect() {
/* all ISP pins are inputs before */
/* now set output pins */
ISP_DDR |= (1
Comments
Add a commentThanks to you, I can finally revive my procs, thanks! [Read more]
Hi, can the 89LP2052 also be programmed with this modified USBasp? Is there a list of compatible chips somewhere? [Read more]
Hi I use avrdude version 6.3-20171130 to operate the programmer. Unfortunately, the list of supported microcontrollers does not include the one you are asking about. In general, the case looks dull,... [Read more]
Great, write to me for a small gift. [Read more]
A few years ago I managed in a simpler way (as for me), I added a single 74HC1G14 gate and a jumper that switches the RESET signal (typical or negated depending on the programmed uC). [Read more]
erm... Some time ago I made this firmware: https://github.com/mamut-tme/UsbAsp-flash_89S52 Support for s51 and s52 works in it without any problems. Patch speeding up sck (it's more for AVR, s51/52... [Read more]
@mlodyzdolny I downloaded your sources and put together the project with the original files, but it doesn't compile in Eclipse. Even the original projects don't compile - something is missing... [Read more]
@wirnick I am compiling in my linux environment (Mint Vera 21.1) using the latest versions of tools around gcc and avr. I use Makefile to compile by running the following command in the firmware directory: ... [Read more]
@mlodyzdolny thank you very much for your response, but the .hex file is independent of the development environment. I am currently programming in MPLAB (after the acquisition of Atmel by Microchip). I'm... [Read more]
Yes, but the tools with which hex is created depend on the environment. There are versions for Linux and Windows, so I gave a short description of my configuration. MplabX can use xc8, but so can gcc.... [Read more]
As usual, I turned around. I was thinking AVR Toolchain and wrote avrdude. Am I to understand that you will no longer share the fruits of your labor? [Read more]
I can share the hex, but in general I think that the sources carry more value, because everyone can change something according to their needs. I'll send something tonight. Perhaps the compilation... [Read more]
hex to my firmware variant (link above). It does not require any modification of the original USBasp schema. Detecting whether it is s5x or avr is automatic. Target initialization tries AVR first, then... [Read more]
@mlodyzdolny thank you very much and you are my Friend! I have achieved success as shown in the attached picture. I made a correction in the #include paths in the file main.ci usbdrv.h and in the file... [Read more]
Unfortunately, I can't help much with that. As it says in the github repo description, my code is a combination of a solution from some nofeletru (from Moscow) and Miles McCoo (from a defunct site,... [Read more]