draft post, published for usefulness not polish
- Hackaday project that introduced me to the CH552 and BASIC-52: Single Chip Computer | Hackaday.io
- Boards that I’ve got this working with:
- CH552 Stick from DeqingSun/ch55xduino (DIY, surface-mount);
- WeAct Studio CH552T Mini Core Board;
- WAVGAT CH552G core board.
- You’ll need an external USB UART with 5 V power, as this port doesn’t support serial over the USB
- Project source (yes, it’s a Google Drive link, and any docs are in Japanese): CH55x. If that doesn’t work, the original redirect is from CH552Eでモニタプログラムを動かしてみました | きょうのかんぱぱ. If neither of those work, here’s my download of the archive: CH552T&G-20240805T141304Z-001.zip
- Binary file (zip): basic52s.bin (hiyodori5, version 7th May 2023, converted from hex so you don’t have to mess with srec_cat or makebin)
- Build cjacker/ch55x-isptool to upload the code (which doesn’t accept hex)
- Plug in the CH552 board. You may have to do something with the boot/reset button to make it turn up as the right USB ID (4348:55e0 WinChipHead).
- Program the board:
sudo ch55xisptool basic52s.bin
- Disconnect the board, and wire it up to the USB UART (5 V, GND, TX → RXD [P3.0], RX → TXD [P3.1])
- Hit return a few times to get a prompt
- PWM is on P1.2, INT1 is on P3.3. See Hackaday project to see how to access I²C, and also do things with SFR values using RDSFR / WRSFR. PORT3 is at SFR(0B0H)
please ignore the following for now …
Who wouldn’t want to run a solid BASIC interpreter on a $3 development board? So maybe there are a couple of drawbacks:
- there’s no way to save the program to non-volatile storage: you have to be connected through a serial terminal at all times; and
- you’ve got about 600 bytes for the whole program, with no way to expand it.
Despite these limitations, there’s some futile fun to be had. I’ll show you how to flash BASIC-52 onto one of these development boards, and give a quick intro to what you can do with it.
BASIC-52
Intel released the first version of BASIC-52 for their 8051 family of microcontrollers in 1984. They produced a chip (8052AH-BASIC) with the interpreter burnt into mask ROM in 1985. The source code was released into the public domain, and various features such as I²C support were added by the community around 2000.
As befits an embedded language, BASIC-52 supports pin management, timers and interrupts. It’s also a fairly full-featured BASIC interpreter with floating point support and mostly familiar keywords and functions. Because it’s designed for very limited memory use, its string handling is quite unlike any other BASIC dialect. It has one character array that you can treat as a string, and a few functions to work with characters, but that’s about all.
A most useful reference is Intel’s MCS BASIC-52 Versions 1 & 1.1 Operating and Reference Manual. Another helpful guide is Jan Axelson’s The Microcontroller Idea Book. I found out about both of these references from Single Chip Computer — Hackaday.io, which also introduced me the possibilities of running BASIC-52 on the CH552.
CH552
You might know WCH (aka QinHeng Electronics) from their inexpensive CH341 USB serial adapters and other interface boards. What you might not realize is that all of their older interface chips are based on an optimized 8051 design