Guest User

Untitled

a guest
Jul 16th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #include <xc.h>
  2. #include "amt.h"
  3. #include <stdio.h>
  4.  
  5. #pragma config XINST = OFF
  6. #pragma config FOSC = HS
  7. #pragma config WDT = OFF
  8.  
  9. void interrupt HighIsr(void) // High priority interrupt
  10. {
  11.  
  12. }
  13.  
  14. void interrupt low_priority LowIsr(void) //Low priority interrupt
  15. {
  16.  
  17. }
  18.  
  19. void main(void) {
  20. int loop_counter = 0;
  21. TRISJ = 0x00; // Configure PORT J as 8 bits output
  22. PORTJ = 0X00; // Off all the LEDs connected to PORT J
  23. T2CON = 0b01111111; // Enable tmr2, prescaler=16, postscaler=16
  24. PR2 = 224; // For 10ms timing with the Fosc = 25 MHz
  25. PIR1bits.TMR2IF = 0; // Clear the flag before using
  26. while (1) {
  27. while (PIR1bits.TMR2IF == 0); // Waiting for tmr2 flag to be set
  28. loop_counter++; // increment loop_counter by 1 every 10ms
  29. if (loop_counter == 50)
  30. {
  31. PORTJ = PORTJ ^ 0b00000001; // Toggle using XOR
  32. // or PORTJbits.RJ0 = PORTJbits.RJ0 ^ 1;
  33. loop_counter = 0;
  34. }
  35. PIR1bits.TMR2IF = 0; // Clear the flag before using
  36. }
  37. }
Add Comment
Please, Sign In to add comment