TIMER/COUNTER UNIT

 

 

 

_CMPB

equ word ptr[bp+6]

;get parameter off the stack

push

ax

;save registers that will be

push

dx

;modified

mov

dx, T1CNT

;Clear Timer 1 Counter

xor

ax, ax

 

out

dx, al

 

mov

dx, T1CMPA

;set time before t_shot to 0

mov

ax, 1

 

out

dx, al

 

mov

dx, T1CMPB

;set pulse time

mov

ax, _CMPB

 

out

dx, al

 

mov

dx, T1CON

 

mov

ax, C002H

;start Timer 1

out

dx, al

 

CountDown:

in ax, dx

;read in T1CON

test

ax, MaxCount

;max count occurred?

jz

CountDown

;no: then wait

and

ax, not MaxCount

;clear max count bit

out

dx, al

;update T1CON

pop

dx

;restore saved registers

pop

ax

 

pop

bp

;restore caller’s bp

ret

 

 

_one_shot

endp

 

lib_80186

ends

 

end

 

 

 

 

 

Example 9-3. Configuring a Digital One-Shot (Continued)

9-23

Page 252
Image 252
Intel 80C188XL, 80C186XL user manual Cmpb