Advertisement
artones

Untitled

Mar 31st, 2021
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.81 KB | None | 0 0
  1. #include <stdio.h>     
  2. #include "C8051F120.h" 
  3. sbit LED = P1^6;           
  4. cnt = 0x10;
  5. // Peripheral specific initialization functions,
  6. // Called from the Init_Device() function
  7. void Reset_Sources_Init()
  8. {
  9. WDTCN = 0xDE;      
  10. WDTCN = 0xAD;
  11. }
  12. void Timer_Init()
  13. {
  14. SFRPAGE = TIMER01_PAGE;
  15. TMOD = 0x01;
  16. }
  17. void Port_IO_Init()
  18. {
  19. SFRPAGE = CONFIG_PAGE; 
  20. P1MDOUT = 0x40;
  21. XBR2 = 0x40;
  22. }
  23. void Interrupts_Init()
  24. {
  25. IE = 0x82;         
  26. }
  27. // Initialization function for device,
  28. // Call Init_Device() from your main program
  29. void Init_Device(void)
  30. {              
  31. Reset_Sources_Init();
  32. Port_IO_Init();
  33. Interrupts_Init();
  34. Timer_Init();
  35. }
  36. Timer_ISR(void) interrupt 1{
  37. TF0 = 0;               
  38. }
  39. void main(void){
  40. Init_Device();
  41. TR0 = 1;               
  42. while (1){             
  43. PCON |= 0x1;           
  44. cnt--;             
  45. if (cnt == 0){         
  46. LED=~LED;              
  47. cnt = 0x10;        
  48. }
  49. }
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement