![]() |
||||||
| Microcontroller Kits Simple
Mikrokontroller 89s51 Trainer All Item Include
|
5.2. Timer Interrupt Application
Step 1st Step 2nd In this experiment, we use Timer 0 mode 1 with vector address timer 0 interrupt 0BH. Note that in this mode, with a 12 Mhz crystal frequency, the timer over flows every 65,536 microsecond. To generate interrupt every 50000 microsecond ( 0,05 second ) then 65536-50000=15536 d = 3CB0 h and data tobe loaded TL0 = B0h dan TH0 = 3Ch. Org 0h
sjmp Start
Org 0bh
Ljmp Interrupt_Timer0
;
Start: mov A,#10000000b
call InitTimer
;
Forever:
mov P0,A
sjmp Forever ;
;
Interrupt_Timer0:
mov tl0,#0b0h
mov th0,#03ch
cpl A
reti
;
InitTimer:
mov TMOD,#00000001b;Timer/Counter 0 as Timer
mov tl0,#0b0h
mov th0,#03ch
setb ET0 ;Enable Timer 0 Interrupt
setb EA ;Enable Master Interrupt
setb TR0 ;Start Running
ret
;
Step 3rd
Comments, questions and discussion about this topic
|
|
||||