You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.6 KiB

  1. #include <msp430fr6989.h>
  2. char lec=0;
  3. int cont1=0,cont2=0,cont3=0,cont4=0;
  4. void main(void)
  5. {
  6. WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
  7. PM5CTL0 = 0x0000;// DESACTIVAR EL MODO DE ALTA IMPEDANCIA
  8. /*Confg. de perifericos */
  9. P1SEL0 = 0x00;
  10. P1SEL1 = 0x00; //SELECCIONAMOS FUNCION COMO I/O DIGITAL
  11. P1DIR = 0x01; //P1.0-> SALIDA P1.1-P1.7-> ENTRADAS
  12. P1REN = 0xFE;
  13. P1OUT = 0xFE;
  14. P1IE = 0x7E;
  15. P1IES = 0x00;
  16. P1IFG = 0x00;
  17. P9SEL0 = 0x00;
  18. P9SEL1 = 0x00; //SELECCIONAMOS FUNCION COMO I/O DIGITAL
  19. P9DIR = 0x80; //P9.7-> SALIDA P9.0-P9.6->ENTRADAS
  20. P9REN = 0x7f;
  21. P9OUT = 0x00;
  22. __enable_interrupt(); //también se puede usar _enable_interrupts()
  23. for(;;)
  24. {
  25. }//loop
  26. }//main
  27. //**************Interruptions**************
  28. #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
  29. #pragma vector=PORT1_VECTOR
  30. __interrupt void inter_puerto1(void)
  31. #elif defined(__GNUC__)
  32. void __attribute__ ((interrupt(PORT1_VECTOR))) PORT1_ISR (void)
  33. #else
  34. #error Compiler not supported!
  35. #endif
  36. {
  37. lec=P1IFG;
  38. lec &= BIT3;
  39. __delay_cycles(250);
  40. if( P1IFG == BIT3){
  41. cont1++;
  42. P1OUT ^= 0x01;
  43. }
  44. lec &= BIT4;
  45. __delay_cycles(250);
  46. if( P1IFG == BIT4){
  47. cont2++;
  48. P9OUT ^= 0x80;
  49. }
  50. lec &= BIT5;
  51. __delay_cycles(250);
  52. if( P1IFG == BIT5){
  53. cont3++;
  54. P1OUT ^= 0x01;
  55. }
  56. lec &= BIT6;
  57. __delay_cycles(250);
  58. if( P1IFG == BIT6){
  59. cont4++;
  60. P9OUT ^= 0x80;
  61. }
  62. P1IFG=0x00;
  63. }