Hello, my name is Sammy.
I try to write an interrupt service routine for the keyboard interrupt. I'm using a Motorola 68HC08 and freescale's Codewarrior. Port A is connected with a button. Port B is connected with LED. If I push the button, LED should switch on. If I push it again LED should switch off.
I'm very unexperienced with C and don't know how to do this.
#include /* for EnableInterrupts macro */ #include "derivative.h" /* include peripheral declarations */
void KBI_init(void) { /* This procedure is to prevent False Interrupts at initialisation*/ KBSCR_IMASKK = 1; /* Mask Keyboard interrupts */ KBIER_KBIE2 = 1; /* Enables pin2 of KBI by setting KBIE2(PTA2)
*/KBSCR_ACKK = 1; /* Clear any false interrupts */ KBSCR_IMASKK = 0; /* Unmask Keyboard interrupts */ /* END Avoidance of False Interrupts */ /* Configures KBI Status & Control Register */ KBSCR = 0; /* IMASKK=0: Clears KBI Mask Bit (Enable Ints)
*//* MODEK=0: Interrupt requests on Falling Edge Only */
}interrupt 15 void _KB_Interrupt (void) { KBSCR_ACKK = 1; /* Acknowledge KB Interrupts */ PTA_PTA1 = ~PTA_PTA1; /* Toggles the LED */ }
// IO_Ports int delay = 5000;
static void Delay(void) { int cnt = 0; while (cnt 0; i