Building a Single Chip Computer is very interesting and fun. We can use the Single Chip Computer for simple programming and interfacing experiments. Normally Single Board Computers(SBC) will have external FLASH or ROM for code memory, external RAM, external clock or oscillator, communication and interfacing I/O port pins which results in higher BOM cost, multiple components in inventory, increased board area and cost. But Single Chip Computers does not require any of them.
Out of many available microcontrollers, 8051 family comes from almost from every manufacturer and many software development tools available for both assembly language or C language.
Intel 8052AH-BASIC microcontroller requires additional external LATCH and atleast 1kB external RAM along with external crystal or oscillator to function as a stand alone computer running BASIC-52.
But after few decades now we can run true Single Chip Computer using just a enhanced 8051 core controller with internal iFLASH, internal xRAM and internal oscillator.
No external device programmer required to program the iFLASH memory. iFLASH can be directly programmed through USB port.
Single Chip Computer runs with BASIC-52 V1.31 along with I2C functions and SFR Read/Write functions included.
These are 1T core compared to conventional 8051 with 12T core. Enhanced 8051 core performs 8~15 times faster than conventional core.
We can fit everything into a small DIP-40 form factor board which enables plug and play replacement for the conventional microcontroller board with the same pinout and form factor.
Compared to other implementation, this Single Chip Computer runs on BASIC-52 and does not requires any external IDE or Compiler like SDCC, Keil, Arduino IDE, etc., The user code directly placed inside the chip's RAM received from the Rx line and runs from the chip. This avoids repeated programming of the IC every time.
OBJECTIVE:The objective of the project is very simple. Make a Single Chip Computer running BASIC-52 using enhanced 8051 core. The board form factor should be equal and compatible with existing DIP-40 600 mils package. The available pins should be mapped to the original DIP-40 package pinout.
The circuit should be very minimal. If possible run with only a single chip.
PROs:- Single chip solution with NO external components.
- Saves component cost, board space and fabrication cost
- No external ROM or RAM chip required. Uses 16kB iFLASH for BASIC and 1kB xRAM for user program
- No external Crystal or Oscillator required. Running at 24MHz internal oscillator
- No external programmer required. Programming via USB or UART port
- PORT1, Tx, Rx, Timer, Interrupt, pins available for user interface!
- Runs 8~15 times faster than conventional controller
- The FLASH is not programmed for every time which saves the life of limited life FLASH
- Limited Memory(1k, 4k or 6k)
- No external memory( Address lines not available)
We can easily overcome the limitations using CH558 or CH559 controllers. Using CH558/CH559 controllers gives the speed advantage of additional 2x since clock running at 48MHz. CH559 comes with 6kB RAM which is good enough for most of the programming needs. Or we can use serial FLASH
The following description shows how we can implement a BASIC-52 single chip computer using CH552 IC. CH552E comes with MSOP-10 package. It is just 3x3mm size. But the number of useful I/O pins are just 4.
CH552G comes in SOP16 package. It has more I/O pins compared to CH552E. Same thing applicable to CH552P IC.
CH552T comes in TSSOP-20 package and having 20 pins having highest pin counts in the CH552 family. CH552 family comes with 16kB iFLASH and 1kB of xRAM.
CH552E does not have UART0 pins mapped to physical IC. So we need to reassign the UART0 traffic to UART1 in the source code.
The souce code was modified by Twitter(X) user @hiyodori5
You can also find CH552E, CH559 code in the Twitter feeds. CH559 code also supports SPI bus access commands apart from I2C bus. There are few commands which supports reading and writing into SFR register area.
BASIC-52 uses dedicated commands related to access the PORT1 of the computer. Since only in CH552T we have all the pins of PORT1 available, it is decided to go with CH552T device.
If you just want to run the BASIC-52 on single chip, you can use any of the commerical available boards which using CH552E, CH552G, CH552P or CH552T. We can also run the CH559 code on CH559 or CH558 eval or dev boards.
The above image shows the board form factor and pin assignment. Since the board was made in DIP-40 size and pins compatible with the original pinout of the 8052 IC. The board is very simple and can be fabricated on two layers. The fabricated board looks like below.
Power supply pins are VCC at pin 40 and GND at pin 20. PORT1 pins 0~7 available which is very useful for interface. Port 1 pin 2 also serves as PWM output which is useful to make any PWM based control or just create some noise or sound using buzzer/speaker. Hardware Reset pin is available at pin 9.
RxD and TxD pins available for primary communication between command input and display output. If we do not want to use the onboard USB-TTL on the other side of the board, we can connect to any off the shelf USB-TTL. Since there is only one IC CH552T running at 24MHz, which consumes very less power, we can draw both the power and Rx, Tx lines from USB-TTL converter. This avoids additonal power source.
INT0, INT1 pins are available. T0, T1 pins are also available. P3.6 and P3.7 pins are available. P3.6 and P3.7 are useful for programming the device Flash memory through USB port.
As per CH552 datasheet, the ROM is an iFlash™ process, which can be programmed about 200 times under 5V power supply for the finished products after the formal packaging of blank ROM.
We need VUSB capacitor and proper supply decoupling for reliable flash programming through USB port. After programming BASIC-52 code, since we are not going to use the USB port anymore, we don't require the VUSB capacitor. By this way we can achive the real 100% Single Chip Computer using BASIC-52. The Flash programming cycle endures for around 200 times. Since we are going to flash only once, we need not to bother about flash programming anymore. If we need to program the device multiple times, there are provision to add the VUSB and other decoupling capacitors on the rear side of the board.
Since there is lot of space available on the DIP-40 size board, decided to add onboard USB-TTL converter. We can directly connect the Single Chip Computer to PC using 4 connections VCC, GND, D- & D+ pins.
The assembled and firmware loaded board looks like below.
LOADING the FLASH:There are many software tools available for both Linux and Windows. The chip vendor provides the WCHISPTool
The test point V33 should be connected to P3.6(UDP) before powering up. After 5V applied, when we remove the P3.6 to V33 connection, the chip enters into loader mode.
If we use onboard USB-TTL IC on the rear side, P33 and D+ should be shorted before applying VCC power to enter USB-TTL converter into loading mode.
The SINGLE CHIP COMPUTER works well only with the CH552 IC. There is no additional components required. I have not added the caps on the TOP layer which simplifies the assembly process only because the title of the project
SINGLE CHIP COMPUTER!
Both top and bottom side view. In the top side only one chip needs to be assembled. Bottom side there is no components needed for wired and wireless operation. There is a optional inbuilt USB-TTL circuit on the rear side which is not required for normal operation.
If we notice closely, only 19 pins are mapped to the original DIP-40 IC version. Pin numbers 18, 19, 21~39 are not connected in DIP-40.
Complete technical description, board design files, test files are available HERE
In the above picture PORT1 is connected with 8 LEDs.
Toggle Port 1 pin 7 at 1Hz using hardware TIMER
10 REM toggles P1.7 once per second
20 TIME=0
30 CLOCK 1
40 DO
50 ONTIME 1,100
60 WHILE 1=1
70 END
100 REM reset time
110 TIME=0
120 REM toggle Port 1, bit 7
130 PORT1=PORT1.XOR.80H
140 PRINT "Port 1, bit 7 = ",(PORT1.AND.80H)/80H
150 RETIRunning eight LEDs left and right
01 REM 8 LED SHIFT WITH CH552
02 REM SHIFT LEFT AND RIGHT
10 LED = 1
20 IF LED <= 80H THEN PORT1 = 0FFH.XOR.LED ELSE GOTO 1000
30 LED = LED * 2
40 FOR J = 0 TO 999 : NEXT J
50 GOTO 20
900 REM RIGHT SHIFT
1000 LED = 080H
1100 IF LED >= 1 THEN PORT1 = 0FFH.XOR.LED ELSE GOTO 10
1120 LED = LED/2
1130 FOR J = 0 TO 999 : NEXT J
1200 GOTO 1100ASCIIART with TIME measurement
001 REM ASCII ART CH552T
005 TIME=0 : CLOCK 1
010 For Y = -12 To 12
020 FOR X=-39 TO 39
030 CA=X*0.0458
040 CB=Y*0.08333
050 A=CA
060 B=CB
070 I=0
080 T=A*A-B*B+CA
090 B=2*A*B+CB
100 A=T
110 IF (A*A+B*B)>4 THEN GOTO 150
120 I=I+1 : IF I<=15 THEN GOTO 80
130 PRINT " ",
140 GOTO 170
150 IF I>9 THEN I=I+7
160 PRINT CHR(48+I),
170 NEXT X
180 PRINT
190 NEXT Y
200 PRINT TIME
210 GOTO 10
220 ENDThis Single Chip Computer is 16 times faster than the classic Intel 8052 running at 11.0592 MHz which takes 409 seconds to complete the same operation. The secret is increase in system clock to 24MHz along with Enhanced 8051 core which almost executes every instruction at 1T except branch and jump operation code.
FREE BOOK and EXAMPLE CODE
The above book and example code available from Jan Axelson Website HERE
The above one is CH552E Single Chip Computer in MSOP-10 package. Note that the IC having only 10 pins compared to CH552T with 20 pins. The IC pin pitch is 0.5mm. Only 4 useful I/O can be used. It is very small form factor and useful for computation intention with limited interface circuit. If we need more I/O then using I2C based 8-bit input/output (I/O) expander like PCF8574 or MCP23017 is a 16-bit input/output expander with an I2C interface can be used very easily. The PCF8574 I2C interface BASIC example program available in the repo. By default the I2C used the PORT1 pins P1.5(SCL) and P1.6(SDA). Since the pin P1.6 already used for Serial communication through Tx & Rx, the I2C SDA pin is reassigned to P1.4 in the source code and compiled.
This Single Chip Computer uses CH552G, another variant from the same CH552 family. It comes with SOP16 package and having lead pitch of 1.27mm. This IC having 16 pins and still the complete PORT 1 pins are not available. Here also we can expand the I/O pins using 8 or 16 bit I/O port expander using I2C bus.
Another closer view of CH552G Single Chip Computer. PORT1 pins P1.0, P1.2 and P1.3 are NOT available. But far better than CH552E compared to available I/O pins.
Easy way to connect with a smartphone is using external USB-TTL converter. Make sure they are compatible with 5V signal levels.
The baud rate should be 19200 and 10ms char delay and 100ms line delay.
There are many vendors provides similar USB-TTL such as CH34x from WCH, Silab CP2102, Prolific, etc., The module comes with different type of USB connector. Make sure you have the right USB cable when you order.
There are readymade smartphone app available for iOS and Android OS.
Using the vendor specific TTY terminal is much easier due to driver availablity.
PC connectivity:For connecting with a Desktop or Laptop, we need a application similar to Putty or TeraTerm.
I have tested with TeraTerm 4 and TeraTerm 5. After selecting the COM port from the List, first fix the Baudrate to 19200 and char delay to 10ms and line delay to 100ms.
We can easily type the source code on a plain ASCII text editor and save BASIC-52 file in the PC. We can easily send to the Single Chip Computer by clicking the Send File option.
Over BLUETOOTH:It is much easier and convenient to operate the computer over Bluetooth UART link using SPP at 19200 baud
We can use any of the available serial port over bluetooth which supplorts 19200 baud. We need to check the default baud of the bluetooth modules using AT commands. If the default baud rate is not 19200, we need to set it. Most of the modules comes with the default baud of 9600. We can also change the Module Name from default name.
The single chip computer can be very easily connected with a smart phone or PC using bluetooth module. We need only one module for the Single Chip Computer and both the Smartphone and PC already having inbuilt Bluetooth.
After turning ON the board, we can search the Bluetooth device using smartphone or computer. There will be 2 serial ports appear in the PC. Once the connection is established, the pairing LED stops blinking and blinks for every 4 seconds.
The above shows the smartphone connected with BASIC-52 computer using bluetooth connection.
We can also connect a bluetooth keyboard and bluetooth mouse to smartphone for easy typing.
Alternative SOLUTION:Those who already have any of the CH552 device can easily create this project without making the board fabrication which is time and cost consuming. Instead just solder the device on the adapter board with 2.54mm pitch. So this way we can easily experiment the device with small breadboard.
After inserting the module into the breadboard, carefully connect the VCC, GND, Tx, Rx along the sufficient decoupling capacitors.
Another much easier way to implement and test is using the off-the shelf demo or dev boards which comes with header, RESET, BOOT switch and some LED. With the readymade board, we just need 4 connections.
Just connect the board to the PC and connect with any terminal app. Set baud to 19200, char delay of 5ms and line delay of 50ms. Now press the connect to establish the connection.
Press the RST button
Now you can start programming or you can send file to the Single Chip Computer over serial port.
You can find more details, documents, video at HERE


Comments