It's been a few years since I got my DS89C450 chips with me. And now only I gonna give it a go with some cool projects. Since PIC and then Arduino became very famous, many hobbyists and embedded fans seems to be leaving the cool 8051 chips.
Oki... lets get to know about the DS89C450 chip. The best thing is about these DS89C4x0 microcontrollers by Maxim is the stable bootloader and they are very easy to program. As per the DS89C450 Datasheet the following are the exciting features of these ICs
- Highest performing 8051 compatible microcontrollers.
- Ultra high speed upto 33MHz and 32MIPS (Million Instructions Per Second)
- 16kB/64kB Flash memory.
- In-System programmable with Serial Port. (There are 2 full duplex serial ports)
- 13 Interrupt sources including 6 External Interrupts.
Programming Hardware
There is a very good and informative application note from Maxim about the full technical details. However the basic Hardware setup would be like below,
The programming software will initiate bring down the chip to the programming mode by setting the DTR of the Serial Port to LOW, thus R1Out will be LOW and EA, PSEN will become LOW and RST will be HIGH. This will kick off the bootloader and the bootloader prompt will be transmitted through the Serial Port 0 of the chip.
And now we are good to load the hex code to the Chip. When the flashing finishes, the programmer will set the DTR of the Serial Port back to HIGH and the chip returns back to the running mode.
I have constructed the above circuit on a small dotboard and wired with the tiny wires uses for wirewrapped constructions. The construction is the same as above, except I have allocate a pin header for export the 4 I/O Ports and also facilitate for the 2nd Serial Port and, (of cause) 5V power regulator. And this makes the board a completed dev board.
Software in Linux
This is very important. In Windows there are pre-built software and it's very easy to use. The first thing I have done after building the circuit was (obviously) connecting the board to a PC with the aid of a USB to RS232 converter. I use minicom with Ubuntu 16.04
Run minicom -s and select Serial port setup and set the parameters. Make sure to select both hardware and software flow control as No. Save the configuration and select Exit. Hit the Enter Key and then you would see the banner from the bootloader.
CONNECTED TO LOADER SUCCESSFULLY
DS89C450 LOADER VERSION 2.1 COPYRIGHT (C) 2002 DALLAS SEMICONDUCTOR
>
I have used sdcc compiler for writing and compiling 80c450 code in Linux environment. Version 2.8.0 worked for me however. For loading I have used the perl script done by Vinu. However I had to make some minor changes according to my hardware setup.
import serial,time,sys,os
os.system("clear")
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"
sys.exit(0)
ser = serial.Serial('/dev/ttyUSB0',9600)
ser.timeout = 0.3
try:
ser.setDTR(1)
except Exception,e:
print "error open serial port: " + str(e)
exit()
if ser.isOpen():
try:
ser.flushInput()
ser.flushOutput()
ser.write("\x0D")
ser.write("\x0D")
time.sleep(0.3)
recbuffer = ser.read(80)
list = recbuffer.split(" ")
print recbuffer
if '>' in recbuffer:
print "CONNECTED TO LOADER SUCCESSFULLY"
print recbuffer
else:
print "CONNECTION ERROR"
ser.setDTR(0)
ser.close()
sys.exit(0)
ser.write("K\x0D")
time.sleep(0.1)
ser.write("L\x0D")
f=open(sys.argv[1],"rU")
hexcontent = f.read()
f.close()
ser.write(hexcontent+"\x0D")
k = ser.read(200)
print k
ser.setDTR(0)
ser.close()
except Exception, e1:
print "error communicating...: " + str(e1)
else:
print "cannot open serial port "
A simple LED Blink program
Ok below is the test program to blink an LED connected to the P0 port.
#include "sdcc_reg420.h"
void delay(unsigned long int i) //delay function
{
while(i != 0){
i--;
}
}
void main(void)
{
while(1){
P0^=255; //PORT0 = PORT0 XOR 1
delay(189000); //calling delay
}
}
Compile the code with sdcc
sdcc led.c
and this will generate led.ihx hex file.
And load the ihx to the chip with the above script
python ./prog.py led.ihx
And.. if everything goes well, the LEDs connected to the Port 0 should blink!!
Await for more and troubleshooting tips.