First the sad news. I found out the other day that the SX line of processors is EOL. So this means that if I want to use something like a SX52 I have to switch to another line of micro-controllers. Which really bites because then I have to get another programmer.
Anyway I will still continue my projects using my SX28 for now.
I also will be attending University doing a BENG in EE in 2010.
Calculator
Now on to the calculator, I’m still working on.
I have tidied up the code. Went through a ruckus because my son a toddler pulled some of the wires out of the breadboard. Took some time to rewire it. I noticed that he knocked some of the resistors together that are used for the 7seg displays. I thought there was an error in the code and tried to debug it only to find out it was a hardware fault.
Design flaws
I have also realised that there are way too many wires the way it is wired up. I have seen cleaner designs, mine has each 7seg driven by its own chip when I could drive them all straight from the micro-controller and switch between them. Also the number of resistors used is way too many because I used common anode 7seg and the 7447 chip. Instead it would have been a cleaner design to use common cathode and 7448. Also then I would not need so many resistors and they could not touch each other. Common Cathode requires more current draw from the chip.
Another problem I have discovered is that neither the 48 or 47 chips can display a negative sign. Also I need extra lines from the micro-controller to get a decimal point.
Keypad
With the help of my Father I have worked out the correct circuit for a keypad. I wrote the code and it works. It took many hours of debugging to get right. The circuit pulls the line to +5V and sends a low to determine if there is a key press.
Option CarryX
After the keypad code worked I decided to work on the Math routines. I started with simple 2 Byte addition and subtraction. I came unstuck when I went to do the subtraction. The problem is that the carry is incorrectly set on the SX28 when you do sub. So when I did a subb the inverted carry made it do subtract when it should not, and not subtract when it should. Eventually I googled around and found a page talking about multi-byte math on the SX. That page uses the option carryX switch to make the SX always use carry during addition and subtraction, instead of manually via subb and addb. However when I added that switch to my code it affected my binary to BCD routines and I don’t know why.
Eventually I decided to remove the carryX option and manually invert the carry after sub. Currently my code is performing a 16 bit number – 8 bit number calculation without error. Later I will finish off the subtraction routine and make the calculator just do addition and subtraction before moving on to multiply and divide. But still I have a problem in that I don’t have a method for displaying a negative number.