Sunday, February 2, 2014

Microcontroller Showdown, Part 3

The next chip I compared was the DS89C450 from Maxim. This is a single-cycle 8051 with clock speeds up to 33MHz. The other single-cycle 8051 I wanted to test is the AT89LP6440 but I wasn't able to program it with an FTDI cable. It expects an SPI interface based on a parallel port and I do not know how to get it working with the FTDI cable.

At first I had a lot of trouble getting the DS89C450 running with the flashing software supplied by Maxim. It just would not connect no matter what crystal or capacitor combination I tried. After a little digging I found out that the baud rate depends on the crystal and that 4800 is the max for 12 and 20MHz crystals. Unfortunately, the flashing software only supports 1200 and 9600 or higher bauds. At 1200 baud I was finally able to connect successfully but the chip returned an error when I tried to load firmware. After more digging it seems the problem is caused by using an FTDI cable instead of a real serial port. I can't really hold this against the manufacturer, though, since the chip and software are over 10 years old at this point. Next I tried connecting over Hyperterminal at 4800 baud and this worked great. The interface for communicating with the chip is actually kind of slick. It gives you a prompt you can type commands into and responds back to your input. Loading firmware at 4800 baud, however, was a real pain. If I decide to seriously use this chip, I will definitely track down a crystal that lets me connect at 57600 baud.

The results of the tests are after the break. I ran them with a 20MHz crystal and scaled the results for what they would probably be with a 33MHz crystal. For compiling I used SDCC. This compiler is new to me but it seems pretty simple to use. In place of -O3 I used --opt-code-speed and for -Os I used --opt-code-size. There wasn't really a difference in the results though. As you can see, it adds 8 bit numbers even faster than the LPC1114, 16 bit numbers about as fast as the MSP430, and 32 bit numbers almost twice as fast. It is also much faster at multiplying than the MSP430, which was a surprise to me. Out of curiosity I looked at the 8051 instruction set and was quite surprised to learn that it has 4-cycle multiplication of 8 bit values. The rest of the instruction set and architecture seems very straightforward and I imagine it would be fun to write assembly code for this chip. Division and shifting are pretty slow. GPIO, however, is very fast. Each pin is mapped to its own byte in memory. This seems like a simple feature and I wish more chips had it. With this the chip can bit bang almost as fast as the LPC1114 can with masks. The real test of the chip, though, is BCD calculations and in this it was pretty disappointing, running 2-3 times slower than the MSP430. For these tests all the data was stored in the on-chip external RAM (xdata). This is slower to access but it was necessary to store it here since the internal RAM holds less than 100 bytes. I also tried storing it in the idata section available in 8052 compatible chips like this but that was even slower. It looks like I won't be using this chip for any calculator designs but I will keep it in case I do a project that needs an external memory interface or memory mapped peripherals.

These tests are not a comprehensive benchmark. Many factors have to be taken into account to choose the right chip for a job. These tests only focus on a very narrow range of those factors.
MSP430G2553
LPC1114
DS89C450
Loop overhead time -O3 1.720.843.33
-Os 1.720.913.33(20MHz)(33MHz)
Add unsigned 8 bit -O3 9.8268.1064.643.86.292.961.79
-Os 9.8898.1694.843.936.242.911.76
Add unsigned 16 bit -O3 10.0328.3124.964.1218.0414.718.92
-Os 10.0718.3515.154.2417.9214.598.84
Add unsigned 32 bit -O3 29.59227.8724.233.3931.4928.1617.07
-Os 29.81628.0964.383.4731.327.9716.95
Add signed 8 bit -O3 9.848.124.633.796.292.961.79
-Os 9.9098.1894.823.916.242.911.76
Add signed 16 bit -O3 10.028.34.633.7918.0514.728.92
-Os 10.0548.3345.154.2417.9214.598.84
Add signed 32 bit -O3 29.53627.8164.23.3631.4928.1617.07
-Os 29.63727.9174.383.4731.3127.9816.96
Multiply unsigned 8 bit -O3 19.6517.931.280.445.311.981.2
-Os 19.5817.861.410.55.281.951.18
Multiply unsigned 16 bit -O3 21.1419.421.280.4412.929.595.81
-Os 21.0719.351.410.512.829.495.75
Multiply unsigned 32 bit -O3 40.3638.641.330.4931.3728.0416.99
-Os 40.2338.511.420.5131.2827.9516.94
Multiply signed 8 bit -O3 19.9818.261.390.555.311.981.2
-Os 19.9118.191.530.625.281.951.18
Multiply signed 16 bit -O3 20.6518.931.390.5512.919.585.81
-Os 20.5818.861.530.6212.829.495.75
Multiply signed 32 bit -O3 70.2468.521.230.3931.3828.0517
-Os 69.9768.251.410.531.1827.8516.88
Divide unsigned 8 bit -O3 17.3415.628.097.255.442.111.28
-Os 17.2715.558.337.425.42.071.25
Divide unsigned 16 bit -O3 29.4427.721110.1675.4372.143.7
-Os 29.3227.611.1410.2374.9872.6543.42
Divide unsigned 32 bit -O3 90.1288.414.5613.72231.16227.83138.08
-Os 89.7588.0314.6513.74229.63226.3137.15
Divide signed 8 bit -O3 33.2731.559.358.518.264.932.99
-Os 33.1331.419.388.478.24.872.95
Divide signed 16 bit -O3 33.723212.0511.2179.3476.0146.07
-Os 33.4731.7512.2911.3878.8975.5645.79
Divide signed 32 bit -O3 96.9495.2215.514.66231.86228.53138.5
-Os 96.5494.8215.5814.67230.46227.13137.65
Shift right unsigned 8 bit -O3 14.8613.141.830.9917.814.478.77
-Os 14.7913.071.961.0517.6714.348.69
Shift right unsigned 16 bit -O3 29.7928.071.830.9962.8659.5336.08
-Os 29.6627.941.971.0662.4659.1335.84
Shift right unsigned 32 bit -O3 69.6267.91.720.88200.46197.13119.47
-Os 69.3167.591.80.89199.32195.99118.78
Shift right signed 8 bit -O3 14.8513.132.161.3220.7417.4110.55
-Os 14.813.082.291.3820.6217.2910.48
Shift right signed 16 bit -O3 25.1523.432.161.3267.7664.4339.05
-Os 25.0523.332.291.3867.3564.0238.8
Shift right signed 32 bit -O3 59.6957.971.720.88209.38206.05124.88
-Os 59.4257.71.80.89208.16204.83124.14
Shift left unsigned 8 bit -O3 14.8613.141.830.9917.8114.488.78
-Os 14.813.081.961.0517.7114.388.72
Shift left unsigned 16 bit -O3 25.1623.441.830.9962.8659.5336.08
-Os 25.0423.321.971.0662.5159.1835.87
Shift left unsigned 32 bit -O3 59.6757.981.720.88200.53197.2119.52
-Os 59.4157.961.80.89199.42196.09118.84
Shift left signed 8 bit -O3 14.8613.142.161.3217.814.478.77
-Os 14.813.082.291.3817.714.378.71
Shift left signed 16 bit -O3 25.1723.452.161.3262.8859.5536.09
-Os 25.0423.322.291.3862.5159.1835.87
Shift left signed 32 bit -O3 59.6857.961.720.88200.55197.22119.53
-Os 59.4157.691.80.89199.44196.11118.85
GPIO -O3 18.08816.3687.036.1915.612.277.44
-Os 18.05616.3367.266.3515.5212.197.39
GPIO Constant Generator -O3 14.75213.032
-Os 14.75813.038
GPIO Masked -O3 3.222.38
-Os 3.522.61
GPIO Bit Operation -O3 8.264.932.99
-Os 8.224.892.96
BCD Add 120+325 -O3 47.9346.2117.9316.21
-Os 50.0548.3320.8319.11
BCD Add 120+325
Stored in xdata
-O3 214.03210.7127.7
-Os 212.13208.8126.55
BCD Add 120+325
Stored in idata
-O3 249.96246.63149.47
-Os 247.78244.45148.15
BCD Multiply 24 * 13
Without multiplies
-O3 393.4391.68131.49129.77
-Os 375.21373.49149.84148.12
BCD Multiply 24 * 13
Without multiplies, xdata
-O3 1441.81438.47871.8
-Os 14371433.67868.89
BCD Multiply 24 * 13
Without multiplies, idata
-O3 1658.31654.971003.01
-Os 1651.81648.47999.07
BCD Multiply 24 * 13
With multiplies
-O3 405.64403.92131.88130.16
-Os 508.52506.8140.53138.81
BCD Multiply 24 * 13
With multiplies, xdata
-O3 1565.11561.77946.53
-Os 15571553.67941.62
BCD Multiply 24 * 13
With multiplies, idata
-O3 1829.51826.171106.77
-Os 1818.91815.571100.35

No comments:

Post a Comment