68HC11 Calculator

By Employee

68HC11 Board:

The primary function of the calculator is for the calculation of two integer numbers. The following features are: The input of calculation variables is done through a 4x4 keypad and displayed on a 16x2 LCD display module.

The keystroke numbers are integers between 1 and 16. The following table shows the integer with their mating LCD character and the mating keypad illustration:

Integer number LCD Character Keypad Illustration
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
8 8 8
9 9 9
10 = a
11 backspace b
12 + c
13 - d
14 * e
15 divide f
16 0 0
The adc is an 8 bit value from channel 7 connected to an board pot that can be turned from 0 up to 255. This is done by using the supplied screwdriver to turn the pot through the hole in the upper left region of the calculator as shown in figure 1.

All calculations are performed by the program extracting the variables from the string MSG1. This string is inputted by the user from the keypad and is displayed on the first line of the LCD display. For example (255*254=). The first variable would be “255”, the second variable being “254” and the calculation function would be “*”.

The first variable is converted from an ASCII integer as string to a single 8-bit number that is stored in a variable. It is also converted into hundreds, tens and ones.

The second variable is also converted from an ASCII integer as string to a single 8-bit number that is stored in a variable. It is also converted into hundreds, tens and ones.

The calculation function is an integer between 1 and 4:


The 68HC11 Calculator

Multiplication:

Multiplication is done using reg A and reg B as follows: A * B = A , B = B + (255 * A) + A


The 68HC11 Calculator performing Multiplication

Division:

Division uses IDIV command and divides variable one by variable two.


The 68HC11 Calculator performing Division

Addition:

Addition is done by adding the ones together and if there is a carry the carry is added to the tens and if the tens has a carry the carry is added to the hundreds, if the hundreds has a carry the carry is finally added to the thousands. This process is then repeated for the tens and then the hundreds. This is the same process as one would use with pen and paper with out a calculator.


The 68HC11 Calculator performing Addition

Subtraction:

Subtraction uses the same process as one would use with pen and paper with out a calculator.


The 68HC11 Calculator performing Subtraction


68HC11 Calculator Code



Partner's Sites