Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWANTIMER HANEL
INTERRUPTS(cont’)
Example 11-4Write a program to generate a square wave if 50Hz frequency on pin P1.2. This is similar to Example 9-12
except that it uses an interruptfor timer 0. Assume that XTAL=11.0592 MHzSolution:ORG 0LJMP MAIN ORG 000BH ;ISR for Timer 0CPL P1.2MOV TL0,#00MOV TH0,#0DCHRETIORG 30H
;--------main programfor initializationMAIN:MOV TM0D,#00000001B ;Timer 0, Mode 1MOV TL0,#00MOV TH0,#0DCHMOV IE,#82H ;enable Timer 0 interruptSETB TR0
HERE:SJMP HEREEND