Advertisement
Guest User

Exercise 4

a guest
Mar 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include "C8051F340.h"
  2.  
  3.  
  4. void main(void){
  5.  
  6. unsigned int a = 0;
  7.  
  8. P2MDOUT = 0x0C; // pullup for LEDs
  9. P0SKIP = 0xFF; // skip P0
  10. P1SKIP = 0xFF; // skip P1
  11. XBR1 = 0x70; //
  12. OSCICN = 0x83; // Internal H-F clock: SYSCLK=12MHz
  13. PCA0MD &= 0xBF; //watchdog configure
  14. PCA0MD = 0x00; //watchdog disable
  15.  
  16.  
  17. TMOD = 0x02; //TIMER 0, 8bits with auto-reload
  18.  
  19. TF0 = 0; //clear flag
  20.  
  21. TL0 = 256 - 250;
  22.  
  23. TH0 = 256 - 250;
  24.  
  25. TR0 = 1;
  26.  
  27. while(1){
  28.  
  29. if(TF0){
  30.  
  31. TF0 = 0;
  32. a++;
  33. if ( a == 2000){
  34. TF0 = 0;
  35.  
  36. P2_3 =! P2_3;
  37. a =0;
  38.  
  39.  
  40. }
  41.  
  42.  
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement