Building a Single Board Computer is very interesting and fun. We can use the Single board computer for simple programming and interfacing experiments. Normally Single Board Computers will have external FLASH or ROM for code memory, external RAM, external clock or oscillator, communication and interfacing I/O port pins.
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.
BASIC-52 Minimum System Requirement
But after few decades now we can run true Single Chip C…
Building a Single Board Computer is very interesting and fun. We can use the Single board computer for simple programming and interfacing experiments. Normally Single Board Computers will have external FLASH or ROM for code memory, external RAM, external clock or oscillator, communication and interfacing I/O port pins.
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.
BASIC-52 Minimum System Requirement
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.
Running BASIC-52 V1.31 along with I2C functions and SFR Read/Write functions included.
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.
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
CONs:
- 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.
CH552E - MSOP10 package - 0.5mm pitch
CH552G comes in SOP16 package. It has more I/O pins compared to CH552E. Same thing applicable to CH552P IC.
CH552G - SOP16 - 1.27mm pitch
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.
CH552T - TSSOP-20 - 0.65mm pitch
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.
CH552 BLOCK DIAGRAM
CONSTRUCTION:
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.
SINGLE CHIP COMPUTER LAYOUT using CH552
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.
SINGLE CHIP COMPUTER - Double sided PCB - DIP40
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.
Assembled BOARD
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!
TOP and BOTTOM view of the 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.
8052AH-BASIC DIP40 IC PINOUT
Complete technical description, board design files, test files are available HERE
Single Chip Computer with integrated USB-TTL connected
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 second20 TIME=030 CLOCK 140 DO 50 ONTIME 1,10060 WHILE 1=170 END 100 REM reset time110 TIME=0120 REM toggle Port 1, bit 7130 PORT1=PORT1.XOR.80H140 PRINT "Port 1, bit 7 = ",(PORT1.AND.80H)/80H150 RETI
Running eight LEDs left and right
01 REM 8 LED SHIFT WITH CH55202 REM SHIFT LEFT AND RIGHT10 LED = 120 IF LED <= 80H THEN PORT1 = 0FFH.XOR.LED ELSE GOTO 100030 LED = LED * 240 FOR J = 0 TO 999 : NEXT J50 GOTO 20900 REM RIGHT SHIFT1000 LED = 080H1100 IF LED >= 1 THEN PORT1 = 0FFH.XOR.LED ELSE GOTO 101120 LED = LED/21130 FOR J = 0 TO 999 : NEXT J1200 GOTO 1100
ASCIIART with TIME measurement
001 REM ASCII ART CH552T005 TIME=0 : CLOCK 1010 For Y = -12 To 12020 FOR X=-39 TO 39030 CA=X*0.0458040 CB=Y*0.08333050 A=CA060 B=CB070 I=0080 T=A*A-B*B+CA090 B=2*A*B+CB100 A=T110 IF (A*A+B*B)>4 THEN GOTO 150120 I=I+1 : IF I<=15 THEN GOTO 80130 PRINT " ",140 GOTO 170150 IF I>9 THEN I=I+7160 PRINT CHR(48+I),170 NEXT X180 PRINT190 NEXT Y200 PRINT TIME210 GOTO 10220 END
ASCIIART downloaded into Single Chip Computer
ASCIIART running at 24.395 seconds
This 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 Microcontroller Idea Book by Jan Axelson
The above book and example code available from Jan Axelson Website HERE
Single Chip Computer - CH552T [BASIC-52]
with external USB-TTL
Wired Connection via external USB-TTL(Optional):
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.
FTDI
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.
FTDI app
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.
TeraTerm Baud and Delay
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
HC-05 BLUETOOTH MODULE
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.
Bluetooth Module
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.
Single Chip Computer with Bluetooth connection
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.
Single Chip Computer running BASIC-52 connected to Android smartphone
The above shows the smartphone connected with BASIC-52 computer using bluetooth connection.
We can also connect a bluetooth keyboard to smartphone for easy typing.