|
|
@ -0,0 +1,78 @@ |
|
|
|
#include <msp430fr6989.h> |
|
|
|
|
|
|
|
|
|
|
|
char lec=0; |
|
|
|
int cont1=0,cont2=0,cont3=0,cont4=0; |
|
|
|
void main(void) |
|
|
|
{ |
|
|
|
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer |
|
|
|
PM5CTL0 = 0x0000;// DESACTIVAR EL MODO DE ALTA IMPEDANCIA |
|
|
|
|
|
|
|
/*Confg. de perifericos */ |
|
|
|
P1SEL0 = 0x00; |
|
|
|
P1SEL1 = 0x00; //SELECCIONAMOS FUNCION COMO I/O DIGITAL |
|
|
|
P1DIR = 0x01; //P1.0-> SALIDA P1.1-P1.7-> ENTRADAS |
|
|
|
P1REN = 0xFE; |
|
|
|
P1OUT = 0xFE; |
|
|
|
P1IE = 0x7E; |
|
|
|
P1IES = 0x00; |
|
|
|
P1IFG = 0x00; |
|
|
|
|
|
|
|
P9SEL0 = 0x00; |
|
|
|
P9SEL1 = 0x00; //SELECCIONAMOS FUNCION COMO I/O DIGITAL |
|
|
|
P9DIR = 0x80; //P9.7-> SALIDA P9.0-P9.6->ENTRADAS |
|
|
|
P9REN = 0x7f; |
|
|
|
P9OUT = 0x00; |
|
|
|
|
|
|
|
__enable_interrupt(); //también se puede usar _enable_interrupts() |
|
|
|
|
|
|
|
for(;;) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
}//loop |
|
|
|
}//main |
|
|
|
|
|
|
|
//**************Interruptions************** |
|
|
|
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) |
|
|
|
#pragma vector=PORT1_VECTOR |
|
|
|
__interrupt void inter_puerto1(void) |
|
|
|
#elif defined(__GNUC__) |
|
|
|
void __attribute__ ((interrupt(PORT1_VECTOR))) PORT1_ISR (void) |
|
|
|
#else |
|
|
|
#error Compiler not supported! |
|
|
|
#endif |
|
|
|
{ |
|
|
|
|
|
|
|
lec=P1IFG; |
|
|
|
lec &= BIT3; |
|
|
|
__delay_cycles(250); |
|
|
|
if( P1IFG == BIT3){ |
|
|
|
cont1++; |
|
|
|
P1OUT ^= 0x01; |
|
|
|
} |
|
|
|
|
|
|
|
lec &= BIT4; |
|
|
|
__delay_cycles(250); |
|
|
|
if( P1IFG == BIT4){ |
|
|
|
cont2++; |
|
|
|
P9OUT ^= 0x80; |
|
|
|
} |
|
|
|
|
|
|
|
lec &= BIT5; |
|
|
|
__delay_cycles(250); |
|
|
|
if( P1IFG == BIT5){ |
|
|
|
cont3++; |
|
|
|
P1OUT ^= 0x01; |
|
|
|
} |
|
|
|
|
|
|
|
lec &= BIT6; |
|
|
|
__delay_cycles(250); |
|
|
|
if( P1IFG == BIT6){ |
|
|
|
cont4++; |
|
|
|
P9OUT ^= 0x80; |
|
|
|
} |
|
|
|
|
|
|
|
P1IFG=0x00; |
|
|
|
} |
|
|
|
|