Single Chip Computer running BASIC-52

We have already seen the power and possibility of running a Single chip computer using CH552. The main limitation with CH552 is the speed of the computer and the useful internal RAM available to the user.

The maximum clock speed of CH552 is 24 MHz. The internal xRAM available to the user is 1kB. Within this 1kB xRAM, the BASIC-52 will allocate around 512 bytes of xRAM for STACK and to keep many other status bits at RAM. We can refer to BASIC-52 manual for for more details.

Enhanced core E8051 based CH558T microcontroller:

The CH55x family consists of CH551, CH552, CH554, CH558 and CH559.

The CH558 and CH559 comes in T & L package which consists of more pins(20 & 48), capable of running at 48 MHz and having more internal xRAM of 4kb and 6kB respectively.

Wireless Bluetooth Connectivity:

For serial communication and keyboard, we need to connect the single chip computer to a PC or Phone. But once we connect it to a phone or PC, we can not change the connection easily.

Instead if we connect the PC or Phone to the Single Chip Computer through a wireless connection using Bluetooth, we can seamlessly transfer the connection. There is no physical connection so we can keep the Single Chip Computer anywhere we want. Even we can keep the computer next room. Only requirement is the range of the bluetooth. We can also keep the computer of a robot or any enclosure without any visibility.

CH558T - SSOP20

If we notice carefully on the above pinout, we can notice PORT3, PORT4 and PORT5 pins are used. We can not directly access any of the PORTs except PORT1 using BASIC-52. So it is easy to go with 20 pin SSOP20 package than 48 pin QFP48 package.

If we have either CH558 or CH559 in any of the package should work.

FIRMWARE:

The source code assembles without any error with Microchip's C51ASM assembler in windows10/11 .C51ASM assembler is available from the microchip website.

There are two changes made to the original file. Since we are going to use the IC at 48 MHz, the default frequency of BASIC-52 source code changed to support 48 MHz. This will help when we execute any time or timer dependent code.

Original code for 11.059200 MHz is

;CONSTANTS
    ;
XTALV:    DB    128+8        ; DEFAULT CRYSTAL VALUE
    DB    00H
    DB    00H
    DB    92H
    DB    05H
    DB    11H
    ;

 Current code for 48.000000 MHz is

;CONSTANTS
    ;
XTALV:    DB    128+8        ; DEFAULT CRYSTAL VALUE
    DB    00H
    DB    00H
    DB    00H
    DB    00H
    DB    48H
    ;

The other change is CH558 uses 4kB internal xRAM compared to CH559 which uses 6kB of xRAM. The range of the internal xRAM is different for CH558 from CH559. The xRAM range for CH558 ranges from 0000H to 0FFFH. So the ERAMEND EQU 0FFFH. This is also corrected to report the proper available memory.

;=== CH558 Added =====
ERAMEND    EQU    0FFFH ; EX-RAM last addr (4KB)
;=====================
;=== CH559 Added =====
;ERAMEND EQU    017FFH ; EX-RAM last addr (6KB)
;=====================
;

CONNECTION:

We need just two wires to the Single Chip Computer namely VCC(+5V) and GND. For this purpose small micro USB breakout board is used for easy connection. We can use any of the available connector or directly connect two wires with correct polarity.

CH558 requires just 4 connections. VCC, GND, Tx and Rx

Bluetooth module requires 4 connections. VCC, GND, Tx and Rx

Some of the Bluetooth modules may support only 3.3V logic level signals. In that case we need to reduce the Tx signal from CH558 to 3.3V for safe and reliable operation.

I2C, SPI and other legacy functions may share the same pin. Please check the pin for any conflict with other functions. We can re-assign the pins and assemble the source code to avoid any conflict.

I2C interface:

;----- Definitions -------------------------------------------------------
; === CH558T ===
SDA        bit    P1.6                    ;I2C serial data line.
SCL        bit    P1.7                    ;I2C serial clock line.

I2CSTART Sends a start condition to I2C bus.

I2CSTOP Sends a stop condition to I2C bus.

I2CPUT [byte]...

Read more »