Motivation

I was searching for something do with the couple of AVR chips I have, as one of my wishlist items is to learn this family. At the same I was reading about the STC family of 8051 descendants and other cheap MCUs. I had thought I would not explore this MCU family any further after my tuner project using an original 8051. I had decided to make STM8 and STM32, far cleaner architectures, my go to MCUs, But I was tempted by the development boards available. Unlike breakout boards, these come with a number of peripherals so you can start making things blink and beep right away. Prices start from $10. With a platform like the Arduino you have to add shields or connect components on breadboard to interface with the outside world. So it will cost about the same.

My primary interest is not the programming as I know that I can beat any architecture into submission, or work out that the hardware is not up to the task. I'm more interested in putting together software toolchains for hardware, so that I can put the MCU to use later. None of what I do is groundbreaking, as others have already shown the way, but I can bring the information together in one place.

When it comes to deployment, you are able to buy the STC89 series in DIP-40 starting around $1. DIP-40 helps if you are learning to design your own PCBs as the larger dimensions of THT parts are more forgiving in the soldering skill department compared to SMT.

Board selection

If you search on Aliexpress or eBay with say "stc89c52 development board" you will get lots of hits. Be aware that boards vary in capability. For example

In the end I chose one with support for AVR chips thus fulfilling one of my original intentions. It's the one depicted in the photos, except that mine has black connectors. Rats, I was hoping for the more attractive yellow connectors. 🙁

Of course, the MCU is not soldered in but mounted in a ZIF socket so you can test other MCUs.

One detail about my board is that the crystal is plug in, not soldered. It comes with a 11.0592 MHz crystal, but you may wish to substitute others depending on the MCU you are experimenting with. But remember the frequency must also conform to any requirements for the serial interface which is used for downloading.

Software

I will mostly discuss Linux based software since this is what I use. But most of what I mention is also available on other OSes.

For the compiler there is SDCC which was originally written to support the 8051. The STC chips have a superset of the 8051 capabilities so you may need additional include files to define them.  The sample programs you can find on the Internet use the Keil compiler on Windows, and there is a free version of that with limited capabilities. You will need to edit those programs somewhat for SDCC. For those of you used to an IDE like Arduino, this may feel like a step backwards. But you'll find there are advantages to working at the command line level.

For downloading the programs to the board there is the stcgal program which is Python based so probably platform-independent.

I found a Github repo with sample programs. The directory names were in Chinese so I forked the repo and renamed the experiment directories to English using Google Translate and some manual editing. Some of the files in the experiments are still using Chinese names. I may fix this by and by. The comments inside the source files are still in Chinese. But the C source should help to understand the hardware. And it will be familiar to anybody who has used the 8051.

There is a datasheet for the MCU in English. Unfortunately I could only find an image of the schematic, not a PDF. There is also an image showing the locations of the various switches, jumpers and connectors.

You will find all these resources in the links or files of this project.

Unpacking the kit

The kit came in a bag with copious bubble wrap around the contents. There was the development board, a USB cable with A connectors on both ends (not usual), 4 plastic standoffs to keep the board off the table surface, and a parallel interface 1602 LCD module.

I connected it to my computer using the USB cable and it started running a test program that was already flashed into the MCU. See the gallery photo.

The CH341 USB interface chip will be recognised by Linux, unless your are running a very old distro (why? 😳). You may want to add a udev rule so that you get permission on the USB device as a user similar to what one does for Arduino. Mine is:

# Set Group for CH341
SUBSYSTEM=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", GROUP="dialout"

My Linux account is a member of the group dialout.

Experiments

As this completes the basic description I will probably write a log for any interesting results I discover while experimenting with the board.