Advertisement
Guest User

123asd

a guest
Sep 18th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #include <xc.h>
  2. #include <htc.h>
  3. #include <stdio.h>
  4.  
  5. #pragma config WDTE=OFF, PWRTE=ON, MCLRE=OFF, CP=OFF, CPD=OFF, BOREN=OFF, IESO=OFF
  6.  
  7. #define FOSC 8000000L
  8.  
  9. unsigned int nsec, punon = 0, sinon = 0, vihon = 0;
  10.  
  11. static void interrupt isr(void) // Keskeytyspalveluohjelma
  12. {
  13. if (T0IF) // ajastimen TIMER0 keskeytyslippu
  14. {
  15. TMR0 = 156;
  16. T0IF = 0;
  17. OPTION_REG = 0x00;
  18.  
  19. if(nsec < 50 ) nsec++;
  20. else
  21. {
  22. nsec = 0;
  23. }
  24.  
  25. if(nsec < punon) RB5 = 1;
  26. else RB5=0;
  27.  
  28. if(nsec < vihon) RB6 = 1;
  29. else RB6 = 0;
  30.  
  31. if(nsec < sinon) RB7 = 1;
  32. else RB7 = 0;
  33.  
  34. }
  35. }
  36. void main(void)
  37. {
  38. OSCCON=0x77;
  39. int punled = 0;
  40. int sinled = 0;
  41. int vihled = 0;
  42. int tila = 1;
  43. unsigned int i = 0;
  44.  
  45. ANSEL = 0;
  46. ANSELH = 0;
  47.  
  48. TRISA = 0xFF;
  49. TRISB = 0x00;
  50. TRISC = 0x00;
  51. PORTA = 0x00;
  52. PORTB = 0x00;
  53. PORTC = 0x00;
  54.  
  55. OSCTUNE=0x0F;
  56.  
  57.  
  58. OPTION_REG = 0x00;
  59. TMR0 = 156;
  60. T0IE = 1;
  61. GIE = 1;
  62.  
  63. for (i = 0; i<60000; i++);
  64.  
  65. while(1)
  66. {
  67. switch(tila)
  68. {
  69. case 1:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement