03.01.2015 Views

80C186EC/80C188EC Microprocessor User's Manual

80C186EC/80C188EC Microprocessor User's Manual

80C186EC/80C188EC Microprocessor User's Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

TIMER/COUNTER UNIT<br />

_CMPB equ word ptr[bp+6] ;get parameter off the stack<br />

push ax ;save registers that will be<br />

push dx ;modified<br />

mov dx, T1CNT ;Clear Timer 1 Counter<br />

xor ax, ax<br />

out dx, al<br />

mov dx, T1CMPA ;set time before t_shot to 0<br />

mov ax, 1<br />

out dx, al<br />

mov dx, T1CMPB ;set pulse time<br />

mov ax, _CMPB<br />

out dx, al<br />

mov dx, T1CON<br />

mov ax, C002H ;start Timer 1<br />

out dx, al<br />

CountDown: in ax, dx ;read in T1CON<br />

test ax, MaxCount ;max count occurred<br />

jz CountDown ;no: then wait<br />

and ax, not MaxCount ;clear max count bit<br />

out dx, al ;update T1CON<br />

pop dx ;restore saved registers<br />

pop ax<br />

pop bp ;restore caller’s bp<br />

ret<br />

_one_shot endp<br />

lib_80186 ends<br />

end<br />

Example 9-3. Configuring a Digital One-Shot (Continued)<br />

9-23

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!