Advertisement
Adytzu04

lab 3 PNS

Mar 4th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1. #include "p33Fxxxx.h"
  2. _FWDT(FWDTEN_OFF);
  3. // Watchdog Timer controlat prin soft
  4. void delay(unsigned int t)
  5. {
  6. unsigned int x;
  7. unsigned int i;
  8. for(i=0;i<650;i++)
  9. for(x=0;x<t;x++);
  10. }
  11.  
  12. void random()
  13. {
  14.     int number;
  15.     number=rand()%4+1;
  16.     if(number==1)
  17.         PORTB=0x7000;
  18.         delay(50);
  19.     if(number==2)
  20.         PORTB=0xE000;
  21.         delay(50);
  22.     if(number==3)
  23.         PORTB=0xD000;
  24.         delay(50);
  25.     if(number==4)
  26.         PORTB=0xB000;
  27.         delay(50);
  28.    
  29. }
  30.  
  31. int main(void)
  32. {
  33. RCONbits.SWDTEN=0;
  34. /* Dezactivare Watch Dog Timer*/
  35. TRISB = 0x0000;
  36. /*setarea pinilor portului B ca iesiri*/
  37. LATB = 0x0000;
  38. /* valoarea din latch-urile de date este 0*/
  39. while(1)
  40. {
  41. random();
  42. //PORTB=0x7000;
  43. //delay(300);
  44. //PORTB=0xE000;
  45. //delay(300);
  46. //PORTB=0xB000;
  47. //delay(300);
  48. //PORTB=0xD000;
  49. //delay(300);
  50. //PORTB=0xE000;
  51. //delay(300);
  52. //PORTB=0x7000;
  53. //delay(300);
  54. //PORTB=0xD000;
  55. //delay(300);
  56. //PORTB=0xB000;
  57. //delay(300);
  58.  
  59. }
  60.  
  61. return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement