Advertisement
artones

Untitled

Mar 29th, 2021
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.34 KB | None | 0 0
  1. #include <stdio.h>
  2. #include "C8051F120.h"
  3. sbit LED=P1^6;
  4.     cnt=0x5;
  5. void Reset_Sources_Init()
  6. {
  7.     WDTCN     = 0xDE;
  8.     WDTCN     = 0xAD;
  9. }
  10.  
  11. void Timer_Init()
  12. {
  13.     SFRPAGE   = TIMER01_PAGE;
  14.     TCON      = 0x10;
  15.     TMOD      = 0x01;
  16. }
  17.  
  18. void Port_IO_Init()
  19. {
  20.     // P0.0  -  Unassigned,  Open-Drain, Digital
  21.     // P0.1  -  Unassigned,  Open-Drain, Digital
  22.     // P0.2  -  Unassigned,  Open-Drain, Digital
  23.     // P0.3  -  Unassigned,  Open-Drain, Digital
  24.     // P0.4  -  Unassigned,  Open-Drain, Digital
  25.     // P0.5  -  Unassigned,  Open-Drain, Digital
  26.     // P0.6  -  Unassigned,  Open-Drain, Digital
  27.     // P0.7  -  Unassigned,  Open-Drain, Digital
  28.  
  29.     // P1.0  -  Unassigned,  Open-Drain, Digital
  30.     // P1.1  -  Unassigned,  Open-Drain, Digital
  31.     // P1.2  -  Unassigned,  Open-Drain, Digital
  32.     // P1.3  -  Unassigned,  Open-Drain, Digital
  33.     // P1.4  -  Unassigned,  Open-Drain, Digital
  34.     // P1.5  -  Unassigned,  Open-Drain, Digital
  35.     // P1.6  -  Unassigned,  Push-Pull,  Digital
  36.     // P1.7  -  Unassigned,  Open-Drain, Digital
  37.  
  38.     // P2.0  -  Unassigned,  Open-Drain, Digital
  39.     // P2.1  -  Unassigned,  Open-Drain, Digital
  40.     // P2.2  -  Unassigned,  Open-Drain, Digital
  41.     // P2.3  -  Unassigned,  Open-Drain, Digital
  42.     // P2.4  -  Unassigned,  Open-Drain, Digital
  43.     // P2.5  -  Unassigned,  Open-Drain, Digital
  44.     // P2.6  -  Unassigned,  Open-Drain, Digital
  45.     // P2.7  -  Unassigned,  Open-Drain, Digital
  46.  
  47.     // P3.0  -  Unassigned,  Open-Drain, Digital
  48.     // P3.1  -  Unassigned,  Open-Drain, Digital
  49.     // P3.2  -  Unassigned,  Open-Drain, Digital
  50.     // P3.3  -  Unassigned,  Open-Drain, Digital
  51.     // P3.4  -  Unassigned,  Open-Drain, Digital
  52.     // P3.5  -  Unassigned,  Open-Drain, Digital
  53.     // P3.6  -  Unassigned,  Open-Drain, Digital
  54.     // P3.7  -  Unassigned,  Open-Drain, Digital
  55.  
  56.     SFRPAGE   = CONFIG_PAGE;
  57.     P1MDOUT   = 0x40;
  58.     XBR2      = 0x40;
  59. }
  60.  
  61. void Interrupts_Init()
  62. {
  63.     IE        = 0x82;
  64. }
  65.  
  66. // Initialization function for device,
  67. // Call Init_Device() from your main program
  68. void Init_Device(void)
  69. {
  70.     Reset_Sources_Init();
  71.     Timer_Init();
  72.     Port_IO_Init();
  73.     Interrupts_Init();
  74. }
  75. void Timer_ISR(void) interrupt 1
  76. {
  77.     TF0=0;  
  78.     cnt --;
  79.     if (cnt==0x00)
  80.     {
  81.         cnt =0x5;
  82.         LED=~LED;
  83.     }
  84. }
  85. void main(void){
  86. Init_Device();
  87. while (1){
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement