Advertisement
abdullahkahraman

Untitled

Jun 24th, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.71 KB | None | 0 0
  1. #include <hidef.h> /* for EnableInterrupts macro */
  2. #include "derivative.h" /* include peripheral declarations */
  3. #include "init.h" // Include the header file that includes I/O definitions
  4.  
  5.  
  6.  
  7. typedef union
  8. {
  9.     unsigned char LEDs;
  10.     struct
  11.     {
  12.         unsigned char bit0 :1;
  13.         unsigned char bit1 :1;
  14.         unsigned char bit2 :1;
  15.         unsigned char bit3 :1;
  16.         unsigned char bit4 :1;
  17.         unsigned char bit5 :1;
  18.         unsigned char bit6 :1;
  19.         unsigned char bit7 :1;
  20.     } bits;
  21. } _LED_register;
  22.  
  23. _LED_register LED_register;
  24.  
  25. interrupt VectorNumber_Vmtim0 void MTIM0_ISR(void)
  26. {
  27.     // Dummily read MTIMx_SC register and
  28.     // then write a 0 to MTIMxSC[TOF]
  29.     MTIM0_overflow = MTIM0_stop;
  30.     LED1 = ~LED1;
  31. }
  32.  
  33. interrupt VectorNumber_Virq_wdog void WDOG_ISR(void)
  34. {
  35.     // Clear the flag by writing 1 to it.
  36.     _WDOG_CS2.Bits.FLG = 1;
  37.     touch_LED = 0;
  38. }
  39.  
  40. void updateLEDs(void)
  41. {
  42.     LED1 = ~LED_register.bits.bit0;
  43.     LED2 = ~LED_register.bits.bit1;
  44.     LED3 = ~LED_register.bits.bit2;
  45.     LED4 = ~LED_register.bits.bit3;
  46.     LED5 = ~LED_register.bits.bit4;
  47.     LED6 = ~LED_register.bits.bit5;
  48.     LED7 = ~LED_register.bits.bit6;
  49.     LED8 = ~LED_register.bits.bit7;
  50. }
  51.  
  52. void main(void)
  53. {
  54.     initialize_CPU();
  55.     initialize_IO();
  56.     show_SRS();
  57.     initialize_MTIM0();
  58.     // initialize_TSI();
  59.     // initialize_ADC();
  60.    
  61.     EnableInterrupts;
  62.    
  63.     //TSI_Trig = 1;
  64.  
  65.     for (;;)
  66.     {
  67.         /*if (TSI_EOSF)
  68.          {
  69.          LED_register.LEDs = TSI_CNTH;
  70.          updateLEDs();
  71.  
  72.          if (TSI_CNTL > 125)
  73.          {
  74.          TSI_LED = 0;
  75.          }
  76.          else
  77.          {
  78.          TSI_LED = 1;
  79.          }
  80.  
  81.          dummy = TSI_EOSF;
  82.          TSI_EOSF = 1;
  83.          TSI_Trig = 1;
  84.          }*/
  85.         LED7 = ~LED7;
  86.         LED8 = ~LED8;
  87.         // __RESET_WATCHDOG(); /* feeds the dog  */
  88.         /* loop forever */
  89.         /* please make sure that you never leave main */
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement