5.2. Timer Interrupt Application
5.2.1. Pulse Generator
The next example implements Timer 0 interrupt for generates pulse generator.
The interrupt generated from Timer 0 overflows TF0. At the begining
data 10000000b will be send out to P0, and after 0,05 second data will
be complemented be 01111111 and send out to P0 again.
Figure 5.2.1. Clock generator with Timer 0 interrupt
Build the circuit as shown in figure 5.2.1. As you seen on figure 5.2.1.
P0.0 is connected to Osciloscope. Remember, that all we want to do with
this lesson is generate clock via P0.0 with timer 0 interrupt
In this step, you must tipe the assembly program to make your Timer
get action, we assume that you have already known the editor, we used
MIDE-51 to edit the program. ( Download File : exp521.zip
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.
Start: mov A,#10000000b
sjmp Forever ;
mov TMOD,#00000001b;Timer/Counter 0 as Timer
setb ET0 ;Enable Timer 0 Interrupt
setb EA ;Enable Master Interrupt
setb TR0 ;Start Running
Safe your assembly program above, and name it with int1.asm (for example)
Compile the program that you have been save by using MIDE-51, see the
Download your hex file ( int1.hex ) into the microcontroller
by using Microcontroller ATMEL ISP software, see the instruction.After
download this hex file you'll see the action of Timer 0 Interrupt ( of
course if your cable connection and your program are corrected ).
questions and discussion about this topic