Advertisement
Guest User

Untitled

a guest
Apr 25th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. #define BP1 PORTB.B1 // RB1 s'appel BP1
  2. #define BP2 PORTB.B2 // RB2 s'appel BP2
  3. #define LED1 PORTA.B0 // RA0 s'appel LED1
  4. #define LED2 PORTA.B1  // RA1 s'appel LED2
  5.  
  6.  
  7. void interrupt()
  8. {
  9.  if (INTCON.INTF == 1)
  10.  {
  11.    if (BP1 == 1)
  12.    {
  13.     LED1 = 1;
  14.    }
  15.    
  16.    if (BP2 == 1)
  17.    {
  18.     LED2 = 1;
  19.    }
  20.    
  21.    else
  22.    {
  23.     LED1 = 0;
  24.     LED2 = 0;
  25.    }
  26.  }
  27. }
  28.  
  29. void main()
  30. {
  31.  CMCON = 7; // comparateur desactivé
  32.  PCON = 0x10; // OSCF a 4MHZ pour oscillateur interne
  33.  INTCON = 0x90; // GIE , INTE actif
  34.  OPTION_REG = 0xc0; // RBPU pull up désactivé , INTDG int rising
  35.  
  36.  PORTA = 0; // int full sortie
  37.  PORTB = 0x01; // int RB0 entrée
  38.  TRISA = 0; // int full 0V
  39.  TRISB = 0; // int full 0V
  40.  
  41.  while(1)
  42.  {
  43.  }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement