Tutorial Microcontroller MCS-51 ATMEL ISP

Microcontroller Kits
Programmer and Target 89s51

Simple Mikrokontroller 89s51 Trainer

Mikrokontroller 89s51 Trainer

Super Mikrokontroller Trainer 89s51


All Item Include





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.

Microcontroller Timer Interrupt

Figure 5.2.1. Clock generator with Timer 0 interrupt


Step 1st
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

Step 2nd
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.

   Org 0h
   sjmp Start
   Org 0bh
Ljmp Interrupt_Timer0
Start: mov A,#10000000b
       call InitTimer
       mov P0,A
       sjmp Forever ; 
       mov tl0,#0b0h
       mov th0,#03ch
       cpl A
       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

Step 3rd
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 software instruction.

Step 4th
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 ).


Comments, questions and discussion about this topic