Advertisement
artones

Untitled

Mar 28th, 2021
313
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $NOMOD51
  2. $include (C8051F120.h)
  3. LED BIT P1.6;
  4. CSEG AT 0;
  5. LJMP MAIN;
  6. ORG 000Bh;
  7. AJMP T0_ISR
  8. ; Peripheral specific initialization functions,
  9. ; Called from the Init_Device label
  10. Reset_Sources_Init:
  11.     mov  WDTCN,     #0DEh
  12.     mov  WDTCN,     #0ADh
  13.     ret
  14. Timer_Init:
  15.     mov  SFRPAGE,   #TIMER01_PAGE
  16.     mov  TL0,       #0h
  17.     mov  SFRPAGE,   #TIMER01_PAGE
  18.     mov  TH0,       #0h
  19.     mov  SFRPAGE,   #TIMER01_PAGE
  20.     mov  TCON,      #010h
  21.     mov  SFRPAGE,   #TIMER01_PAGE
  22.     mov  TMOD,      #001h
  23.     ret
  24. Port_IO_Init:
  25.     mov  SFRPAGE,   #CONFIG_PAGE
  26.     mov  P1MDOUT,   #040h
  27.     mov  XBR2,      #040h
  28.     ret
  29. Interrupts_Init:
  30.     mov  IE,        #082h
  31.     ret
  32.  
  33. ; Initialization function for device,
  34. ; Call Init_Device from your main program
  35. Init_Device:
  36.     lcall Reset_Sources_Init
  37.     lcall Port_IO_Init
  38.     lcall Timer_Init
  39.     lcall Interrupts_Init
  40.     ret
  41. T0_ISR:    
  42.     CLR TF0;
  43.     DJNZ R0, OUT;
  44.     MOV R0, #05h;
  45.     CPL LED;
  46. OUT:    
  47.     RETI;
  48. MAIN:
  49.     lcall Init_Device;
  50.     CLR LED;
  51.     MOV R0, #05h;
  52.     SETB TR0;
  53.     JMP $;
  54. end
Advertisement
RAW Paste Data Copied
Advertisement