hi,
could some one help me to make a calculator connected to a DSP? This is for my real time systems project.
the software used to complile is Code Composer Studio. DSP used in TI TMS320C6711.
keypad is 4x4 Matrix X,Y type.
I could not understand how to make the calculator do basic operations such as add subtract etc.
this is the codes written to recognise the key pressed using timer interrupt. but i could not understand how to incorporate function of doing the basic operations of adding subtractin etc.. could someone help me with adding?? i can figure the other operations from there.
#include <stdio.h>
#include "timer_lib.h"
#include "keypad_lib.h"
char read_keypad_rowj();
char read_keypad_rowk(); /* note the students will have to create row2-row4 read routines */
char read_keypad_rowl();
char read_keypad_rowm();
char read_keypad_rowj()
{
int y; /* define local variable */
char temp;
unsigned int *InputPort0 = (unsigned int *) 0xA0000000; /* First Input Port Address */
unsigned int *OutputPort1 = (unsigned int *) 0xA0000008; /* First Output Port Address */
temp='x'; /* default value for when the key has not been recognised by this function */
*OutputPort1 = 0x00; /* clear keypad inputs */
*OutputPort1= 0x01; /* energise only row 1 of the keypad matrix */
y=*InputPort0; /* read the output of the keypad matrix */
y&=0xF0; /* mask to reset irrelevant bits to 0 */
if (y != 0) /* if one of the lines has been set, check which one it is */
{
if (y == 0x10)
temp = '1'; /* function return value for the key "1" */
if (y == 0x20)
temp = '2'; /* function return value for the key "2" */
if (y == 0x40)
temp = '3'; /* function return value for the key "3" */
if (y == 0x80)
temp = 'F'; /* function return value for the key "F" */
//printf("%c\n",temp);
}
return(temp);
}
char read_keypad_rowk()
{
int y; /* define local variable */
char temp;
unsigned int *InputPort0 = (unsigned int *) 0xA0000000; /* First Input Port Address */
unsigned int *OutputPort1 = (unsigned int *) 0xA0000008; /* First Output Port Address */
temp='x'; /* default value for when the key has not been recognised by this function */
*OutputPort1 = 0x00; /* clear keypad inputs */
*OutputPort1= 0x02; /* energise only row 2 of the keypad matrix */
y=*InputPort0; /* read the output of the keypad matrix */
y&=0xF0; /* mask to reset irrelevant bits to 0 */
if (y != 0) /* if one of the lines has been set, check which one it is */
{
if (y == 0x10)
temp = '4'; /* function return value for the key "4" */
if (y == 0x20)
temp = '5'; /* function return value for the key "5" */
if (y == 0x40)
temp = '6'; /* function return value for the key "6" */
if (y == 0x80)
temp = 'E';/* function return value for the key "E" */
//printf("%c\n",temp);
}
return(temp);
}
char read_keypad_rowl()
{
int y; /* define local variable */
char temp;
unsigned int *InputPort0 = (unsigned int *) 0xA0000000; /* First Input Port Address */
unsigned int *OutputPort1 = (unsigned int *) 0xA0000008; /* First Output Port Address */
temp='x'; /* default value for when the key has not been recognised by this function */
*OutputPort1 = 0x00; /* clear keypad inputs */
*OutputPort1= 0x04; /* energise only row 3 of the keypad matrix */
y=*InputPort0; /* read the output of the keypad matrix */
y&=0xF0; /* mask to reset irrelevant bits to 0 */
if (y != 0) /* if one of the lines has been set, check which one it is */
{
if (y == 0x10)
temp = '7'; /* function return value for the key "7" */
if (y == 0x20)
temp = '8'; /* function return value for the key "8" */
if (y == 0x40)
temp = '9'; /* function return value for the key "9" */
if (y == 0x80)
temp = 'D'; /* function return value for the key "D" */
//printf("%c\n",temp);
}
return(temp);
}
char read_keypad_rowm()
{
int y; /* define local variable */
char temp;
unsigned int *InputPort0 = (unsigned int *) 0xA0000000; /* First Input Port Address */
unsigned int *OutputPort1 = (unsigned int *) 0xA0000008; /* First Output Port Address */
temp='x'; /* default value for when the key has not been recognised by this function */
*OutputPort1 = 0x00; /* clear keypad inputs */
*OutputPort1= 0x08; /* energise only row 4 of the keypad matrix */
y=*InputPort0; /* read the output of the keypad matrix */
y&=0xF0; /* mask to reset irrelevant bits to 0 */
if (y != 0) /* if one of the lines has been set, check which one it is */
{
if (y == 0x10)
temp = 'A'; /* function return value for the key "A" */
if (y == 0x20)
temp = '0'; /* function return value for the key "0" */
if (y == 0x40)
temp = 'B'; /* function return value for the key "B" */
if (y == 0x80)
temp = 'C'; /* function return value for the key "C" */
//printf("%c\n",temp);
}
return(temp);
}