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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

TIMER/COUNTER UNIT<br />

pop dx ;restore saved registers<br />

pop bx<br />

pop ax<br />

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

ret<br />

_clock endp<br />

lib_80186 ends<br />

end<br />

Example 9-2. Configuring a Square-Wave Generator (Continued)<br />

$mod186<br />

name example_timer1_1_shot_code<br />

; FUNCTION: This function generates an active-low one-shot pulse<br />

; on Timer 1 output pin.<br />

;<br />

; SYNTAX: extern void far one_shot(int CMPB);<br />

;<br />

; INPUTS: CMPB - This is the T1CMPB value required to generate a<br />

; pulse of a given pulse width. This value is calculated<br />

; from the formula below.<br />

;<br />

; CMPB = (req_pulse_width*f)/4<br />

;<br />

; OUTPUTS: None<br />

;<br />

; NOTE: Parameters are passed on the stack as required by<br />

; high-level languages<br />

T1CNT equ xxxxH ;substitute register offsets<br />

T1CMPA equ xxxxH<br />

T1CMPB equ xxxxH<br />

T1CON equ xxxxH<br />

MaxCount equ 0020H<br />

lib_80186<br />

assume<br />

public<br />

_one_shot<br />

segment public ’code’<br />

cs:lib_80186<br />

_one_shot<br />

proc far<br />

push bp ;save caller’s bp<br />

mov bp, sp ;get current top of stack<br />

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

9-22

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

Saved successfully!

Ooh no, something went wrong!