DS89C430 development with linux (SDCC compiler and pyserial based hex loader )

I got an 8051 mini board containing DS89C430 mcu from a junk.. Then I started collecting some information about it's development in linux. I came to know that the burning of DS89C430 is very easy since it have a built in UART bootloader.. So I had written a small python code (based on pyserial) to make it more easier.....


The DS89C430, DS89C440, and DS89C450 offer the highest performance available in 8051-compatible microcontrollers. They feature newly designed processor cores that execute instructions up to 12 times faster than the original 8051 at the same crystal speed. Typical applications will experience a speed improvement up to 10x. At 1 million instructions per second (MIPS) per megahertz, the microcontrollers achieve 33 MIPS performance from a maximum 33MHz clock rate. Almost all programs written for the original 8051 will be working in the DS89C430, similar to that of 8051 , with improved execution speed. The reverse may not be possible because it have many extra features which is not there in the traditional 8051 microcontroller......

  •  High speed 8051 architecture
  • One Clock-Per-Machine Cycle
  • DC to 33 MHz operation
  • Single cycle instruction in 30ns
  • 16kB Flash Memory + 1kB SRAM
  • In-Application programmable
  • In-System Programmable through serial port
  • Two full-Duplex serial ports
  • 13 interrupt sources (six external)
  • Five level of interrupt priority


We can use SDCC - Small Device C Compiler for compiling C codes for 8051 and other 8051 compatible microcontrollers like DS89C430 and many more. 
The manufacturer provides a very good application note which focus on the use of SDCC to develop firmware for the DS89C430/450 family. We can copy the  "sdcc_reg420.h" file from the same app note. Also, here is the user's guide and data sheet for the DS89C430/450 family. Also, we could install the SDCC by searching SDCC in the Synaptic Package Manager.
Hello World Program:
C program for LED blinking
//led blinking example for DS89C430//
#include "sdcc_reg420.h"
void delay(unsigned long int i) //delay function
    while(i != 0){
void main(void)
        P0^=1;    //PORT0 = PORT0 XOR 1
        delay(400000); //calling delay

Now save the above code to 'led.c' and use command sdcc led.c ('led.c' and 'sdcc_reg420.h' is now in home folder) to compile the code. Now we could see the led.ihx and some other files generated. The led.ihx is nothing but the intel hex format file which is to be burned into the target microcontroller....


Loading the hex file to the mcu could be done via a simple UART interface since the mcu have a built in ROM loader (a built in boot loader). This is the ISP programming (in circuit programming).
Procedure is very simple, what we need to do is just to interface the serial port 0 of the mcu with a PC (via UART ie (RS232 + MAX232)). We need to invoke the rom loader mode for the ISP programming. The procedure is well explained in the user's guide (link provided at top).

Invoking the ROM Loader Mode

The ROM loader mode is invoked by simultaneously applying a logic 1 to the RST pin, a logic 0 to the EA pin, and driving the PSEN pin to a logic 0 level. If power were to cycle while the required input stimuli were present, the loader would be invoked on power-up. When the ROM loader mode is invoked, the device awaits an incoming <CR> character (0Dh) on serial port 0 at a baud rate that can be detected by the autobaud routine.

Exiting the Loader

To exit ROM loader mode, first float the PSEN signal, and then float or drive the RST pin low. The RST pin has an internal pulldown. The
PSEN signal is an output and drives itself high. When the loader stimulus is removed, the processor performs a hardware reset and
begin execution at location 0000h. Note that both of these conditions must occur, or the loader is exited.

We can use the DTR of the serial port to invoke the ROM loader mode . Below is the circuit diagram from the user's guide.

Now, we need to send some commands to the microcontroller for erasing flash, loading flash, reading memory etc. The list of commands are there in the user's guide.

 I wrote a small python code for sending the commands and the hex file to the microcontroller via serial port. This is based on pyserial. Earlier I used to do it using terminal emulators but I feel it much difficult to type the commands, send the hex file etc...So I did it all in a python script and the procedure is very simple ie we need to give the ihx file name as the command line argument ...

Python script to make the program loading much easier:  (PYSERIAL)
Just need to specify the *.ihx file name in command line argument.
#DS89C430/DS89C450 ROMLOADER   #
#by Vinod.S                    #
import serial,time,sys,os
if not sys.argv[1:]:
    print "hex file not specified in command line argument\n\n"
    print "usage:\npython romloader.py filename.ihx\n\n"
    print "example:\n python romloader.py ledblink.ihx\n\n"
ser = serial.Serial("/dev/ttyUSB0",57600)
ser.timeout = 0.3
except Exception,e:
    print "error open serial port: " + str(e)
if ser.isOpen():
        recbuffer = ser.read(80)
        list = recbuffer.split(" ")
        if 'LOADER' in recbuffer:
            print recbuffer
            print "CONNECTION ERROR"
        hexcontent = f.read()
        k = ser.read(200)
        print k
    except Exception, e1:
        print "error communicating...: " + str(e1)
    print "cannot open serial port "
Note: In my case, it is a USB to SERIAL converter and thus I am using
port as /dev/ttyUSB0. Also, my crystal frequency is 11.0592. At this frequency, the baud rate 57600 comes under the range of auto baud rate. For any other crystal frequency, we need to confirm the baud rate 57600 comes under the specified range, otherwise we need to modify it in the above code to a value which comes under the range of auto baud rate at that particular frequency...

Save above python code as "romloader.py" and input the hex (ihx) file as command line argument..
for example,

python romloader.py led.ihx
Now, after typing above command, if we could see a line with all letters as "G" in terminal, then it shows that the loading is successful. (see below screen shoot)


  1. Recently I came across STC12C5A60S2 (STC-51.com). That has the fast 1T operation too. I compared it with PIC18f452. At the same crystal frequency (I used 11.0592MHz), PIC could catch up with STC-51 when its internal clock multiplier (x4 PLL) was enabled. STC has a lot of built-in peripherals (such as ADC/SPI/UART/On chip EERPOM). I am impressed by this inexpensive chip, but not sure about its reliability. Since the manufacturer is based in China, the English documentation and technical support is almost non-existent. They do have an English manual which includes some sample codes. Wondering if people are using it for real world applications other than for hobby/toy purposes.

  2. Great Article Vinu. Worked well for me and had to do some very little changes according to my hardware setup. All th best!