1.

What are the modes of operations in 8253?

Answer»

There are five modes of operations in 8253

MODE 1: HARDWARE RETRIGGERABLE ONE-SHOT 

OUT will be initially high. OUT will go low on the CLK pulse following a trigger to begin the one shot pulse,and will remain low until the Counter reaches zero. OUT will then go high and remain high until the CLK pulse after the next trigger.After writing the Control Word and initial count, the Counter is armed. A trigger results in loading the Counter and setting OUT low on the next CLK pulse,thus starting the one-shot pulse. An initial count of N will result in a one-shot pulse N CLK cycles in duration. The one-shot is retriggerable, hence OUT will remain low for N CLK pulses after any trigger. The one-shot pulse can be repeated without rewriting the same count into the counter. GATE has no effect on OUT.If a new count is written to the Counter during a one shot pulse, the current one-shot is not affected unless the counter is retriggered. In that case, the Counter is loaded with the new count and the one shot pulse continues until the new count expires.

MODE 2: RATE GENERATOR 

This Mode functions like a divide-by-N counter. It is typically used to generate a Real Time Clock interrupt.OUT will initially be high. When the initial count has decremented to 1, OUT goes low for one CLK pulse. OUT then goes high again, the Counter reloads the initial count and the process is repeated.Mode 2 is periodic; the same sequence is repeated indefinitely. For an initial count of N, the sequence repeats every N CLK cycles. GATE e1 enables counting; GATE e 0 disables counting. If GATE goes low during an output pulse,OUT is set high immediately. A trigger reloads the Counter with the initial count on the next CLK pulse; OUT goes low N CLK pulses after the trigger. Thus the GATE input can be used to synchronize the Counter.After writing a Control Word and initial count, the Counter will be loaded on the next CLK pulse. OUT goes low N CLK Pulses after the initial count is written.This allows the Counter to be synchronized by software also.Writing a new count while counting does not affect the current counting sequence. If a trigger is received after writing a new count but before the end of the current period, 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 the end of the current counting cycle. In mode 2, a COUNT of 1 is illegal. 

MODE 3: SQUARE WAVE MODE

Mode 3 is typically used for Baud rate generation.Mode 3 is similar to Mode 2 except for the duty cycle of OUT. OUT will initially be high. When half the initial count has expired, OUT goes low for the remainder of the count. Mode 3 is periodic; the sequence above is repeated indefinitely. An initial count of N results in a square wave with a period of N CLK cycles. GATEe1 enables counting; GATE e 0 disables counting. If GATE goes low while OUT is low, OUT is set high immediately; no CLK pulse is required. A trigger reloads the Counter with the initial count on the next CLK pulse. Thus the GATE input can be used to synchronize the Counter. After writing a Control Word and initial count, the Counter will be loaded on the next CLK pulse. This allows the Counter to be synchronized by software also.Writing a new count while counting does not affect the current counting sequence. 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 loadedat the end of the current half-cycle.Mode 3 is implemented as follows:Even counts: OUT is initially high. The initial count is loaded on one CLK pulse and then is decremented by two on succeeding CLK pulses. When the count expires OUT changes value and the Counter is reloaded with the initial count. The above process is repeated indefinitely. Odd counts: OUT is initially high. The initial count minus one (an even number) is loaded on one CLK pulse and then is decremented by two on succeeding CLK pulses. One CLK pulse after the count expires,OUT goes low and the Counter is reloaded with the initial count minus one. Succeeding CLK pulses decrement the count by two. When the count expires, OUT goes high again and the Counter is reloaded with the initial count minus one. The above process is repeated indefinitely. So for odd counts,OUT will be high for (N a 1)/2 counts and low for(N b 1)/2 counts.

MODE 4: SOFTWARE TRIGGERED STROBE 

OUT will be initially high. When the initial count expires,OUT will go low for one CLK pulse and then go high again. The counting sequence is ``triggered''by writing the initial count. GATE e1 enables counting; GATE e 0 disables counting. GATE has no effect on OUT.After writing a Control Word and initial count, the Counter will be loaded on the next CLK pulse. This CLK pulse does not decrement the count, so for an initial count of N, OUT does not strobe low until N a1 CLK pulses after the initial count is written.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 a two-byte count is written,the following happens: 

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.This allows the sequence to be ``retriggered'' by software. OUT strobes low N a 1 CLK pulses after the new count of N is written.231164±11 MODE 

5: HARDWARE TRIGGERED STROBE (RETRIGGERABLE)

OUT will initially be high. Counting is triggered by arising edge of GATE. When the initial count has expired,OUT will go low for one CLK pulse and the n go high again.After writing the Control Word and initial count, the counter will not be loaded until the CLK pulse after at rigger. This CLK pulse does not decrement the count, so for an initial count of N, OUT does not strobe low until N a 1 CLK pulses after a trigger. A trigger results in the Counter being loaded with the initial count on the next CLK pulse. The counting sequence is retriggerable. OUT will not strobe low for N a 1 CLK pulses after any trigger. GATE has no effect on OUT.If a new count is written during counting, the current counting sequence will not be affected. If a trigger occurs after the new count is written but before the current count expires, the Counter will be loaded with the new count on the next CLK pulse and counting will continue from there.



Discussion

No Comment Found

Related InterviewSolutions