ee345: introduction to microcontrollers register and counters
DESCRIPTION
EE345: Introduction to Microcontrollers Register and Counters. Prof. Ahmad Abu-El-Haija. Acknowledgement. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/1.jpg)
EE345: Introduction to Microcontrollers
Register and Counters
Prof. Ahmad Abu-El-Haija
![Page 2: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/2.jpg)
April 20, 2023Digital System Design 2
Acknowledgement
This presentation is a modified version of lecture notes prepared by Dr. M. Sachdev, University of Waterloo, other slides from unidentified authors, and original slides from the publisher.
![Page 3: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/3.jpg)
April 20, 2023EE345 - Introduction to Microcontrollers 3
Contents
Registers Shift Registers Ripple Counters Synchronous Counters Other Counters
![Page 4: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/4.jpg)
4
Registers
Registers Register is a group of flip-flops. Each flip-flop is
capable of storing one bit of information. n-bit register has n flip-flops. Can hold n bits of binary data. Register may also contain combinational logic that
determines how information is transferred into register.
A counter is essentially a register that goes through a predetermined sequence of states.
![Page 5: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/5.jpg)
5
4-Bit Register
• Common clock input triggers all ff’s on positive edge of each pulse, and binary data available at inputs are transferred into register.
• Clear input is asynchronous
![Page 6: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/6.jpg)
6
Register with Parallel Load
Specific control signal to load n-bit data
• Load =0, register retains the data
• Load = 1, register accepts new data.
![Page 7: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/7.jpg)
7
Shift Register
Capable of shifting data in one or both directions• Clock controls the shift operation Figure shows a simple shift register with left to
right data shifting capability
![Page 8: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/8.jpg)
8
Serial Data Transfer
Serial mode Data is transferred one bit at a time
![Page 9: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/9.jpg)
Serial Transfer Example
April 20, 2023EE345 - Introduction to Microcontrollers 9
![Page 10: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/10.jpg)
10
Serial Addition
Parallel adders• Faster,• cost more logic Serial adders• Slower• n-bit addition →
n clock cycles• Less hardware
![Page 11: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/11.jpg)
State Table for Serial Adder
April 20, 2023EE345 - Introduction to Microcontrollers 11
JQ = x yKQ = x’ y’ = (x + y)’S = x y Q
![Page 12: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/12.jpg)
12
Second Form of Serial Adder
![Page 13: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/13.jpg)
13
Universal Shift Register
![Page 14: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/14.jpg)
14
Ripple Counters
Counters are available in two categories: ripple counters and synchronous counters.
In a ripple counter, the flip-flop output transition serves as a source for triggering other flip-flops.
In a synchronous counter, the C inputs of all flip-flops receives the common clock.
Binary and BCD ripple counters
![Page 15: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/15.jpg)
15
Ripple (Asynchronous) Counter
Counts the binary sequence
• Negative edge triggered
• Output of one flipflop → clock to the next
• Clock skew adds up
![Page 16: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/16.jpg)
Binary Count Sequence
April 20, 2023EE345 - Introduction to Microcontrollers 16
![Page 17: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/17.jpg)
17
BCD Ripple Counter
A decimal counter follows a sequence of ten states and returns to 0 after the count of 9. Counter must reset itself after counting the terminal count.
A decimal counter follows a sequence of ten states and returns to 0 after the count of 9. Counter must reset itself after counting the terminal count.
![Page 18: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/18.jpg)
18
Q1 changes state after each clock pulse.
Q2 complements every time Q1 goes from 1 to 0 as long as Q8 = 0. When Q8 becomes 1, Q2 remains at 0.
Q4 complements every time Q2 goes from 1 to 0.
Q8 remains at 0 as long as Q2 or Q4 is 0. Q8 is cleared on the next transition of Q1.
BCD Ripple Counter
![Page 19: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/19.jpg)
19
Three-Decade Decimal BCD Counter
![Page 20: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/20.jpg)
20
Synchronous Counter
Common clock is applied to all ff’s.
Clock skew does not add up. Faster than ripple counters. Design of synchronous binary
counter is so simple that there is no need to go through sequential logic design process, but can be used.
FF in least significant position is complemented with every pulse. A ff in any other position is complemented when all the bits in lower significant positions = 1.
![Page 21: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/21.jpg)
21
Up-Down Counter
Can count up (0000 →1111) or down (1111 → 0000) binary sequence
![Page 22: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/22.jpg)
22
Synchronous BCD CounterDesign a synchronous BCD counter with T flip-flops
![Page 23: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/23.jpg)
23
4-Bit Binary Counter with Parallel Load
Count is inhibited when is Load enabled
![Page 24: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/24.jpg)
April 20, 2023EE345 - Introduction to Microcontrollers 24
4-Bit Binary Counter with Parallel Load
![Page 25: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/25.jpg)
25
BCD Counter with Parallel Load
![Page 26: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/26.jpg)
April 20, 2023EE345 - Introduction to Microcontrollers 26
A circuit with n flip-flops has 2n states• We may have to design a counter with a given sequence (unused states)• Unused states may be treated as don’t care or assigned specific next state• Outside noise may cause the counter to enter unused stateMust ensure counter eventually goes to the valid state
Counter with Unused States
![Page 27: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/27.jpg)
27
Counter with Unused States
![Page 28: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/28.jpg)
28
Ring Counter
A ring counter is a circular shift register with only one flip-flop being set at any particular time, all others are cleared.
The single bit is shifted from one flip-flop to the next to produce the sequence of timing signals.
The timing signals can be generated also by a 2-bit counter that goes through four distinct states.
To generate 2n timing signals, we need either a shift register with 2n flip-flops or an n-bit binary counter together with an n-to-2n-line decoder.
![Page 29: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/29.jpg)
29
Generation of Timing Signals
![Page 30: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/30.jpg)
30
Johnson Counter
A k-bit ring counter circulates a single bit among the flip-flops to provide k distinguishable states.
The number of states can be doubled if the shift register is connected as a switch-tail ring counter.
A switch-tail ring counter is a circular shift register with the complement output of the last flip-flop connected to the input of the first flip-flop.
In general, a k-bit switch-tail ring counter will go through a sequence of 2k states.
![Page 31: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/31.jpg)
31
Construction of a Johnson Counter
Number of states of a ring counter can be doubled
![Page 32: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/32.jpg)
Other Counters
April 20, 2023EE345 - Introduction to Microcontrollers 32
![Page 33: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/33.jpg)
33
A 2-Bit Asynchronous Counter
![Page 34: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/34.jpg)
34
3-Bit Asynchronous Counter
![Page 35: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/35.jpg)
35
Clocked Asynchronous Decade Counter
![Page 36: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/36.jpg)
36
A Synchronous 3-Bit Binary Counter
![Page 37: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/37.jpg)
37
4-Bit Synchronous Binary Counter
![Page 38: EE345: Introduction to Microcontrollers Register and Counters](https://reader035.vdocuments.mx/reader035/viewer/2022062422/5681322c550346895d988a8b/html5/thumbnails/38.jpg)
38
3-Bit Counter