Close

A quick foray into the CH552 MCU

ken-yapKen Yap wrote 11/28/2022 at 02:20 • 3 min read • Like

The CH552 is a very cheap (~$1) enhanced 8051 core MCU by Nanjing Qinheng Microelectronics, It's been on the market for a while and there are breakout board projects based on it, for example #CH552 Dragon , #CHUSBIE552 - CH552 Development board , #CH55xG Tiny on Hackaday alone. An Internet search will find many more. So this is old territory. Seeing cheap WeActStudio CH552 boards on AliExpress for less than $2 prompted me to get a couple to play with, despite being a bit adverse to the 8051 CPU architecture. (A decent C compiler can hide some of the ugliness.) This has the CH552 in a 20 pin package and an impressively small number of glue components. The board is only about the size of old 24 pin 0.6 inch width DIP chips. Even the 5V to 3.3V regulator is on the MCU chip. It's similar to other 20 pin MCU boards like the STM8 budget series.

The previous link is to a Github repo and you may wish to make a local clone to get access to the board details. The datasheets from the manufacturer, in both Chinese and English, are also provided.

One of the attractions of the CH55x series is on-chip support for USB which could come in useful for working with USB devices. In fact the USB connector is USB3, not the older USB2 micro USB connector. Today I just want to get it to blink.

For this I will be using Deqing Sun's CH55xduino, which is an Arduino environment for the CH55x devices. The best place to get it is from the official Arduino repositories, search for ch55x under Boards. This provides a familiar starting point for many people. SDCC, the compiler, isn't a C++ compiler, so the object oriented aspects of some Arduino libraries have to be rewritten in plain C, and user code adapted to suit. CH55xduino has made commendable progress on this front. Later on, I'll probably invoke SDCC directly from Makefiles.

For Linux, CH55sduino suggests installing a udev rule so that you can download code as a normal user. I modified it a bit, the original made the USB port RW to all. Instead I chowned it to the dialout group, which is the suggested group for accounts that need to communicate with serial devices on my Linux distro.

# CH55x bootloader
# copy to /etc/udev/rules.d/
SUBSYSTEM=="usb", ATTRS{idVendor}=="4348", ATTRS{idProduct}=="55e0",GROUP="dialout"

To get the blink sketch, I went to Examples and chose the CH55x version. One thing has to be edited, the definition for LED_BUILTIN has to be changed to 30, because the WeActStudio board has the LED on this line, by looking at the schematic from their git repo.

So all I had to do was select Upload, and after a while the blue LED duly blinked.

Now that I know it works, it'll go into my collection of MCU breakout boards which I will put to use when I get a round tuit. There seems to be a worldwide shortage of round tuits, but we all have to cope in our own way.

Like

Discussions