Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include <xc.h>
  2. #include <stdint.h>
  3.  
  4. uint8_t INT_CNT = 0; //initialisation of an interrupt counter
  5.  
  6. void interrupt INTERRUPT_InterruptManager(void) {
  7.  
  8.     if (INT_CNT == 4) {
  9.         INT_CNT = 0;
  10.     }
  11.     if (PIR4bits.TMR2IF == 1 && PIE4bits.TMR2IE == 1) //is interrupt "valid"
  12.     {
  13.     switch (INT_CNT) {
  14.         case 0: LATC = 0x10;
  15.             break;
  16.         case 1: LATC = 0x20;
  17.             break;
  18.         case 2: LATC = 0x40;
  19.             break;
  20.         case 3: LATC = 0x80;
  21.             break;
  22.                      }
  23.     }
  24.     PIR4bits.TMR2IF = 0; //clear interrupt flag
  25.     INT_CNT++;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement