rpy_srijon2008
Newbie level 6

Interrupt Help.
I have made a simple Program with 7 segment LCD and 3x4 keypad with a
Interrupt function in MikroC 8051 Pro as below: -
//=========================================
unsigned short kp;
// Keypad module connections
sfr char keypadPort at P2;
// End Keypad module connections
void Interrupt0ex0(void) org 0x0003 ilevel 0 {
kp=248;
P0=kp;
}
void main() {
Keypad_Init(); // Initialize Keypad
EA=1; //Enable Universal Interrupt
EX0=1; //Enable External Interrupt0
IE0=1;
do {
kp = 0; // Reset key code variable
// Wait for key to be pressed and released
do
kp = Keypad_Key_Click(); // Store key code in kp variable
while (!kp);
// Prepare value for output, transform key to it's ASCII value
switch (kp) {
case 1: kp = 249; break; // 1 // Uncomment this block for keypad4x4
case 2: kp = 164; break; // 2
case 3: kp = 176; break; // 3
case 4: kp = 136; break; // A
case 5: kp = 153; break; // 4
case 6: kp = 146; break; // 5
case 7: kp = 130; break; // 6
case 8: kp = 131; break; // B
case 9: kp = 248; break; // 7
case 10: kp = 128; break; // 8
case 11: kp = 144; break; // 9
case 12: kp = 198; break; // C
case 14: kp = 192; break; // 0
}
P0=kp;
} while (1);
}
I have tried it in Labcenter Proteus and found the following Result.
Whenever I start Debugging[Playing] it the Display is 7 [As for Interrupt].
But My question is why this happens? I haven't made any Interrupt Signal yet.
What is the way to Stop this?
Thanks.
I have made a simple Program with 7 segment LCD and 3x4 keypad with a
Interrupt function in MikroC 8051 Pro as below: -
//=========================================
unsigned short kp;
// Keypad module connections
sfr char keypadPort at P2;
// End Keypad module connections
void Interrupt0ex0(void) org 0x0003 ilevel 0 {
kp=248;
P0=kp;
}
void main() {
Keypad_Init(); // Initialize Keypad
EA=1; //Enable Universal Interrupt
EX0=1; //Enable External Interrupt0
IE0=1;
do {
kp = 0; // Reset key code variable
// Wait for key to be pressed and released
do
kp = Keypad_Key_Click(); // Store key code in kp variable
while (!kp);
// Prepare value for output, transform key to it's ASCII value
switch (kp) {
case 1: kp = 249; break; // 1 // Uncomment this block for keypad4x4
case 2: kp = 164; break; // 2
case 3: kp = 176; break; // 3
case 4: kp = 136; break; // A
case 5: kp = 153; break; // 4
case 6: kp = 146; break; // 5
case 7: kp = 130; break; // 6
case 8: kp = 131; break; // B
case 9: kp = 248; break; // 7
case 10: kp = 128; break; // 8
case 11: kp = 144; break; // 9
case 12: kp = 198; break; // C
case 14: kp = 192; break; // 0
}
P0=kp;
} while (1);
}
I have tried it in Labcenter Proteus and found the following Result.
Whenever I start Debugging[Playing] it the Display is 7 [As for Interrupt].
But My question is why this happens? I haven't made any Interrupt Signal yet.
What is the way to Stop this?
Thanks.