#include
#include “derivative.h”
#define ON 0
#define OFF 1
#define LED1 PTFD_PTFD 0
#define SW1
#define SW2
void main(void) {
Enable_Interrupts; /*enable interrupts */
SOPT_COPE = 0;
PTFDD_PTFDD0 = 1; // Inicializa puerto para LED
PTFDS_PTFDS0 = 1;
PTGDD_PTGDD0 = 0; // Iinicializa puerto para SW
PTGDD_PTGDD1 = 0;
PTGDD_PTGPE0 = 1;
PTGDD_PTGPE1 = 1;
//Inicializa KBI enSW1 y SW2
KBISC_KBIMOD = 0; // Solo transición
KBIPE_KBIPE0 = 1; //Habilita pines de KBI
KBIPE_KBIPE1 = 1;
KBISC_KBIE = 1; // Habilita interrupciónn de KBI
For(;;) {
// __RESET_WATCHDOG(); /*feeds the dog*/
} /*loop forever*/
/* please make sure that you never leave main */
}
void interrupt 26 isrkbi(void) { //26 corresponde a la isr para KBI
if(SW1 == ON)
LED1 = ON;
If(SW2 == ON)
LED1 == OFF;
KBISC_KBACK = 1; //Confirma haber recibido y atendido la interrupciónn.
}
No hay comentarios:
Publicar un comentario