Microprocessors and Microcontrollers: Unit IV: (b) Programmable Interrupt Controller (PIC) - 8259 : Programming Examples
Programming Examples
Example 10.5.1 Write a program to initialize counter 2 in mode 0 with a count of C030H. Assume address for control register = OBH, counter 0 = 08H, counter 1 = 09H and counter 2 = 0AH.
Solution : Control word :
Source Program :
MVI A, BOH
OUT 0BH ; Loads control word (B0H) the control register.
MVI A, lowbyte (30H)
OUT 0AH ; Loads lower byte of the count.
MVI A, higher byte (C0H) ; Loads higher byte of the count.
OUT 0AH
Example 10.5.2 Write a program to generate a square wave of 1 kHz frequency on OUT 1 pin of 8253/54. Assume CLK1 frequency is 1 MHz and address for control register = 0BH, counter 1 = 09H and counter 2 = 0AH
Solution : To get square wave mode 3 is selected count should be 1 MHz / 1 kHz = 1000
Control word :
Source program :
MVI A, 77H
OUT 0BH ; Loads control word (77H) in the control register.
MVI A, Lowerbyte(00) ; Loads lower byte of the count
OUT 09H
MVI A, Higherbyte(10) ; Loads higher byte of the count
OUT 09H
Microprocessors and Microcontrollers: Unit IV: (b) Programmable Interrupt Controller (PIC) - 8259 : Tag: : Microprocessors and Microcontrollers - Programming Examples