Clock This Is The Clock Input For The Counter
Clock This Is The Clock Input For The Counter
• 1) The output will be initially low after the mode set operation.
• 2) After the count is loaded into the selected count Register the output
will remain low and the counter will count.
• 3) When the terminal count is reached the output will go high and
remain high until the selected count is reloaded.
• 1)Gate = 1 enables counting.
• 2) Gate = 0 disables counting.
Let us set channel 0 in mode 0
START: MVI A, 30
OUT 0CEH
MVI A, 05
OUT 0C8H
MVI A, 00
OUT 0C8H
HLT
Observe, using an CRO that the output of channel 0 is initially low. After giving six clock
pulse the output goes high
MODE 1 : Hardware Retrigger able One-shot
a) Normal operation
1) The output will be initially high
2) The output will go low on the CLK pulse following the rising edge at the
gate input.
3) The output will go high on the terminal count and remain high until the
next rising edge at the gate input.
b) Retriggering
The one shot is retrigger able, hence the output will remain low for the
full count after any rising edge of the gate input.
c) New count
If the counter is loaded during one shot pulse, the current one shot is not
affected unless the counter is retriggered. If retriggered, the counter is
loaded with the new count and the one-shot pulse continues until the
new count expires.
START: MVI A, 32
OUT 0CEH
MVI A, 05
OUT 0C8H
MVI A, 00
OUT 0C8H
OUT 0D0H ;triggers gate 0
HLT
MODE 2 : Rate generator
This mode functions like a divide by-N counter.
a) Normal Operation
1) The output will be initially high.
2) The output will go low for one clock pulse before the terminal count.
3) The output then goes high, the counter reloads the initial count and the
process is repeated.
4) The period from one output pulse to the next equals the number of input
counts in the count register.
b) Gate Disable
1) If Gate = 1 it enables a counting otherwise it disables counting (Gate = 0 ).
2) If Gate goes low during an low output pulse, output is set immediately
high. A trigger reloads the count and the normal sequence is repeated.
c) New count The current counting sequence does not affect when the new
count is written. If a trigger is received after writing a new count but
before the end of the current period, the new count will be loaded with
the new count on the next CLK pulse and counting will continue from the
new count. Otherwise, the new count will be loaded at the end of the
current counting cycle.
Using mode 2, divide the clock preset
at channel 1 by 10
START: MVI A, 74
OUT 0CEH ;channel 1 in mode 2
MVI A, 0AH ;LSB of count
OUT 0CAH
MVI A, 00H ;MSB of count
OUT 0CAH
HLT
Mode 3 Square Wave Rate Generator
a)Normal operation
1) Initially output is high.
2) For even count, counter is decremented by 2 on the falling edge of each clock pulse. When the
counter reaches terminal count, the state of the output is changed and the counter is
reloaded with the full count and the whole process is repeated.
3) If the count is odd and the output is high the first clock pulse (after the count is loaded)
decrements the count by 1. Subsequent clock pulses decrement the clock by 2. After timeout,
the output goes low and the full count is reloaded. The first clock pulse (following the reload)
decrements the count by 3 and subsequent clock pulse decrement the count by two. Then
the whole process is repeated. In this way, if the count is odd, the output will be high for
(n+1)/2 counts and low for (n-1)/2 counts.
b) Gate Disable
If Gate is 1 counting is enabled otherwise it is disabled. If Gate goes low while output is low,
output is set high immediately. After this, When Gate goes high, the counter is loaded with
the initial count on the next clock pulse and the sequence is repeated.
c) New Count
The current counting sequence does not affect when the new count is written. If a trigger is
received after writing a new count but before the end of the current half-cycle of the square
wave, the counter will be loaded with the new count on the next CLK pulse and counting will
continue from the new count. otherwise, the new count will be loaded at end of the current
half-cycle.
To generate a square wave of
frequency 150 KHz at channel
START: MVI A, 36
OUT 0CEH
MVI A, 0A
OUT 0C8H
MVI A, 00
OUT 0C8H
HLT
Vary the frequency by varying the count . Here the maximum count is FFFF. Thus with
the clock frequency of 1.5 MHZ, which corresponds to 0.6 micro sec
MODE 4 : Software Triggered Strobe
a) Normal operation
1) The output will be initially high
2) The output will go low for one CLK pulse after the terminal count (TC).
3) And become high again
b) Gate Disable
• If Gate is one the counting is enabled otherwise it is disabled. The Gate
has no effect on the output.
c) New count
• If a new count is written during counting, it will be loaded on the next CLK
pulse and counting will continue from the new count. If the count is two
byte then
1) Writing the first byte has no effect on counting.
2) Writing the second byte allows the new count to be loaded on the next CLK
pulse.
MODE 5 : Hardware triggered strobe
Retriggerable
a) Normal operation
• 1) The output will be initially high.
• 2) The counting is triggered by the rising edge of the Gate.
• 3) The output will go low for one CLK pulse after the terminal count (TC).
b) Retriggering
If the triggering occurs on the Gate input during the counting, the initial count is
loaded on the next CLK pulse and the counting will be continued until the terminal
count is reached.
• c) New count
• If a new count is written during counting, the current counting sequence will
not be affected. If the trigger occurs after the new count is written but before the
terminal count, the counter will be loaded with the new count on the next CLK
pulse and counting will continue from there.