Exploring STC MCU Part 1 – The chips

It seem to me that there are some interest in ultra cheap microcontrollers. The Chinese brand STC makes a few 8051-compatible MCU which sells at ridiculously cheap prices.

Since they are cheap, I grabbed a few to experiment with. The “a few” – 2 each unless there is a minimum order amount greater than that – turned out to be a good stash of chips, and this entire order costd me $15, shipping from Shenzhen included: (weird as those are made in Shanghai, but they don’t have a store front here.)

STC microcontrollers with unified Flash for both code and data.
STC microcontrollers with unified Flash for both code and data.
  • 2x IAP15W4K61S4-30I-PDIP40
  • 2x IAP15F2K61S2-28I-PDIP40
  • 2x IAP15L2K61S2-28I-PDIP40
  • 2x IAP15F2K61S2-35I-SKDIP28
  • 5x IAP15W413AS-35I-DIP20
  • 5x IAP15W413AS-35I-DIP16
  • 5x IAP15W105-35I-DIP8

Those IAP-prefixed STC chips implemented a modified Harvard architecture: while it is binary compatible with traditional 8051 architecture, the data Flash access registers can access the entire internal code (or in this case, unified) Flash space. (while the ones with STC prefix have semi-separated program and data Flash address spaces.)

STC OCD chips
STC chips with unified Flash and on-chip debug capability.

All STC chips requires in-system programming using their proprietary protocol and tool that is Windows-only, and their Visual Basic 6 code are so broken that it won’t even work under Wine if you are UNIX person. The bright side is that the required hardware is simply a serial connection (you can, in fact, bypass their so-called programmer hardware entirely and use your usual USB to Serial module.) ISP uses the usual UART0 pins P3.0 and P3.1 regardless of the existence of UART hardware. But UART0 itself, if exist, can be multiplexed to other pins, so the hardware can still be used. The IAP chips with 2K or more RAM also comes with on-chip debug feature using the in-system program interface. This on-chip debug also uses their in-system program interface and only works with Keil uVision IDE. Since I hate simulators this is going to be my way stepping through the code and figure out what is going on.

If you are trying to get the chips or the tools, be aware that their website is noisy and ad-heavy.

Experiment setup

Most of the experiments in this series will be attempted on this chip, clocked at 30MHz.
Most of the experiments in this series will be attempted on this chip, clocked at 30MHz.

For the experiments I have the same basic setup:

  • IAP15W4K61S4-30I-PDIP40 clocked at 3024MHz
  • STC U8W-Mini ISP/ICD probe connected to P3.0/P3.1 as the ISP/OCD interface.
  • USB to Serial adapter connected to P3.6/P3.7 as the UART0 interface.
  • Reset button for entering ISP mode
  • LED on P2.7 through a MOSFET.

3 thoughts on “Exploring STC MCU Part 1 – The chips”

    1. First off, I am Chinese, there is this symbolic patriotism involved. Second, what made you think you should rely on this brand?

      I have checked the STM8 line. They cost about the same as those 8051s here if not slightly more (keep in mind that SMT packages are cheaper than DIP even though the silicon is the same inside,) but they are not available in PDIP packages (prevents easy prototyping) and not really readily available in the city I live in.

  1. This is a great blog series you’re doing! I’ve always been interested in the STC parts, as they come in prototype-friendly DIP packages, range from 8-40 pins, and offer a ton of system resources — all for pretty incredible prices. These blog posts helped encourage me to hop on AliExpress and buy some of this stuff and start playing with it.

    I just have a few notes to add for STC beginners:
    – STC microcontrollers are 8051-based. When I first started learning 8051, I was coming from the ARM world where the core is standardized, and the peripherals are vendor-specific. Not true for 8051 parts — most manufacturers implement the “base” 8051 peripherals, plus a few vendor-specific peripherals and configuration registers. Unlike other 8051-compatible MCU vendors such as Silicon Labs, you’re going to find almost no information in the STC datasheets that covers the base 8051 features; they sort of assume you’ve got experience with the 8051. That’s why the datasheets seem so brief; all they cover is the differences from the base 8051.

    – While STC has a few different web sites (this seems common for Chinese semiconductor manufacturers), stcmicro.com is the best one for English-language datasheets and downloads.

    – The STC-ISP app is sort of your one-stop shop for everything; it’s far more than just a programmer; it contains header files, demo code, timer configuration tools, and other goodies. It’s actually kind of a cool idea that I wish other vendors would implement.

    – Coming from Silicon Labs 8051 parts, I found the debugging experience strange and under-documented. What you need to know: the STC parts have no on-chip debugger. Instead, STC provides a “monitor” firmware image you can load on the MCU, which you can then connect to from Keil. A “stock” STC part has no way of programming its own flash memory (you have to remember that ISP flash memory programmer built into the chip is a completely different circuit that the CPU has no access to). To debug your code using the STC monitor application, your MCU has to be able to reprogram its own code while running; for this, you have to purchase the special “IAP” versions of the STC parts. These are a more expensive, but for hobbyists, there’s really no reason to get the non-IAP versions. To get it working, click on Keil ICE Settings in the STC-ISP app, and choose “Set IAPxxx as ICE MCU” — this will install the STC monitor firmware image on your MCU. When you choose “Add STC ICE driver to Keil” you’ll be able to choose the STC Monitor-51 driver from the Target Options in Keil. When you hit “Start Debugging” in Keil, it will communicate with the monitor firmware image to program your code into flash memory, and start running it. Once it’s debugging, you can set breakpoints, inspect memory, etc.

Leave a Reply