Advertisement
Guest User

timer_asm

a guest
Nov 20th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. void Timer_Init(void)
  2. {
  3.     __asm
  4.     MOV TMOD, #01H          ;Setting Timer 0 to Mode 1
  5.     MOV IE, #82H            ;Enabling interrupts, and turning on Timer 0 interrupt
  6.     MOV P1, #00H            ;Setting P1 low
  7.     MOV A, #0AH         ;Accumulator contains number of times to wait for
  8.                     ;timer interrupt before toggling the LED
  9.     MOV R1, #00H            ;R1 is used to check for Timer interrupt, using it to
  10.                     ;make ISR as small as possible
  11.     MOV TH0, #4BH           ;Timer register values to calculate 50 ms
  12.     MOV TL0, #0FFH         
  13.     MOV TCON, #10H          ;Start the timer
  14.     __endasm;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement