Presentation is loading. Please wait.

Presentation is loading. Please wait.

LOGIC FAMILIES. Logic Families Logic families are sets of chips that may implement different logical functions, but use the same type of transistors and.

Similar presentations


Presentation on theme: "LOGIC FAMILIES. Logic Families Logic families are sets of chips that may implement different logical functions, but use the same type of transistors and."— Presentation transcript:

1 LOGIC FAMILIES

2 Logic Families Logic families are sets of chips that may implement different logical functions, but use the same type of transistors and voltage levels for logical levels and for the power supplies.

3 Logic Families TTL: Transistor-Transistor Logic BJTs are used. Introduced commercially in 1963 and still in production, though phasing out. High energy consumption, but relatively insensitive to electrostatic discharge (ESD) ECL: Emitter-Coupled Logic BJTs are used. Invented in High energy consumption, but can be designed for extremely high speeds. CMOS: Complementary Metal-Oxide-Semiconductor FETs are used. Invented in First large volume application is in Considerably lower energy consumption than TTL and ECL, which has made portable electronics possible. BIMOS or BICMOS Combination of BJTs and FETs in the same circuit.

4 Naming Convention Logic gates that start with a “54” meet a much more stringent specification on temperature operation than logic gates that start with “74”. Most consumer electronics are build with “74” type of logic gates. “74 __ XX” where: the __ are one to three letters from the English alphabet that indicate the type of transistors that are used to fabricate the logic gate the XX are a set of two-to-four Arabic numbers that indicate the type of logic gate (e.g., AND gate)

5

6 Interface Circuits If you use multiple logic families in a system design: You will likely need to use a voltage translator to insure that a logical “0” and logical “1” are recognized as the signal moves from one logic family to another. You may also need a current source to provide enough current into or out of the BJT-based logic. Something to keep in mind when designing your microprocessor project.

7 Electronic Design Project The logical output voltages from the mbed are 0V and 3.3V. From the datasheet of the Maxum LED driver MAX7219CNG Thus, the logical high of the mbed will be interpreted as an undefined logical level by the LED driver.

8 Solutions Voltage comparator Is it fast enough for the data rate on the SPI output of the mbed? What is the power consumption of the operational amplifier compared to other alternatives? Simple Transistor Inverter or Buffer Lowest power consumption if you select the correct transistor and resistor. IC Inverter or Buffer

9 MAX7219CNG LED Driver Note that the LED driver is compatible with SPI, QSPI, and MICROWIRE inputs. There are SPI (Serial Peripheral Interface) pins on the mbed to send data to the LED driver. Chapter 7 of Fast and Effective Embedded System Design by R. Toulson and T. Wilmshurst

10 SERIAL PERIPHERAL INTERFACE SPI for short Toulson, R. & Wilmshurst, T. (2012). Fast and Effective Embedded Systems Design - Applying the ARM mbed, Newnes, Oxford, ISBN:

11 Serial Communication The mbed has many serial communications capabilities for communicating externally and to control other hardware SPI; I 2 C, CAN, USB Lets take a tour around SPI to get a feel for how these types of protocol work. Further details can be found on the mbed website. Serial Peripheral Interface (SPI) bus operateswith a master/slave configuration SPI is a synchronous serial data communication protocol

12 Introducing Serial Data Communication In serial data transfer, one bit of the data is transmitted at a time, along a single interconnection, accompanied by as many other interconnections as are needed to define bit timing, word framing, and other control data. While slower than parallel data communication, the small number of wires needed is a huge advantage in terms of PCB tracks, interconnecting wires, and IC pins.

13 An 8-Bit Shift Register – a Possible Receiver and/or Transmitter of Serial Data The Basics of a Serial Port: the Shift Register An essential feature of most serial links is a shift register. This is made up of a string of D flip-flops, connected so that the output of one is connected to the input of the next. Each flip-flop holds one bit of information. Every time the shift register is pulsed by the clock signal, each flip-flop passes its bit on to its neighbour on one side, and receives a new bit from its other neighbour. The one at the input end clocks in data received from the outside world, and the one of the output end outputs its bit.

14 Synchronous serial data Introducing Synchronous Serial Communication Once we start applying the serial concept, a number of challenges arise. How does the receiver know when each bit begins and ends, and how does it know when each word begins and ends? A straightforward approach is to send a clock signal alongside the data, with one clock pulse per data bit. The data is synchronised to the clock. This idea, called synchronous serial communication, is shown here.

15 Serial link A simple serial data link is shown. Node 1 is designated Master; it controls what’s going on, as it controls the clock. The Slave (Node 2) is similar to the Master, but receives the clock signal from the Master.

16 Serial Peripheral Interface (SPI) In the early days of microcontrollers, both National Semiconductors and Motorola started introducing simple serial communication, based on the previous Figure. Each formulated a set of rules which governed how their microcontrollers worked, and allowed others to develop devices which could interface correctly. These became de facto standards. Motorola called its standard Serial Peripheral Interface (SPI), and National Semiconductors called theirs Microwire. They’re very similar to each other. An SPI network with one Master and multiple slaves can be constructed as shown.

17 SPI on the mbed: Master FunctionsUsage SPICreate a SPI master connected to the specified pins formatConfigure the data transmission mode and data length frequencySet the SPI bus clock frequency writeWrite to the SPI Slave and return the response The mbed has two SPI ports, each can be configured as Master or Slave. The application programming interface ( API) summary for SPI Master is shown. On the mbed, as with many SPI devices, the same pin is used for SDI if in Master mode, or SDO if Slave. Hence this pin gets to be called MISO, Master in, Slave out. Its partner pin is MOSI.

18 ModePolarityPhase The mode is a feature of SPI that allows choice of which clock edge is used to clock data into the shift register (indicated as “Data strobe” in the diagram), and whether the clock idles high or low. For most applications the default mode, i.e. Mode 0, is acceptable. SPI on the mbed: Mode

19 Clock Polarity and Phase The SPI protocol uses 4 signals clock (SCLK) ModePolarityPhase

20 Clock Data is synchronised to the clock When there is no data being sent, there is no signal on the clock line Every time the clock pulses, one bit is output by the transmitter and should be read by the receiver The receiver synchronises its reading of the data with an edge of the clock. Bit 0Bit 2 Bit 3 Bit 4Bit 5 Bit 6 Bit 7 Master Shift Register ClockClock msb lsb Slave Shift Register msb lsb SDOSDI SDO SCLK Parallel Read/write Parallel Read/write SDO – serial data out SDI – serial data in SCLK – serial clock Bit 1 Serial data

21 /* Program Example 7.1: Sets up the mbed as SPI master, and continuously sends a single byte */ #include "mbed.h“ SPI ser_port(p11, p12, p13); // mosi, miso, sclk char switch_word ; //word we will send int main() { ser_port.format(8,0); // Setup the SPI for 8 bit data, Mode 0 operation ser_port.frequency( ); // Clock frequency is 1MHz while (1){ switch_word=0xA1; //set up word to be transmitted ser_port.write(switch_word); //send switch_word wait_us(50); } SPI Master Program This program shows a setup for a SPI Master. It initialises the SPI port, choosing for it the name ser_port, with the pins of one of the possible ports being selected. The format( ) function requires two variables, the first is the number of bits, and the second is the mode. This program simply applies default values, i.e. 8 bits of data, and Mode 0 format.

22 /*Program Example 7.2. Sets the mbed up as Master, and exchanges data with a slave, sending its own switch positions, and displaying those of the slave. */ #include "mbed.h" SPI ser_port(p11, p12, p13); // mosi, miso, sclk DigitalOut red_led(p25); //red led DigitalOut green_led(p26); //green led DigitalOut cs(p14); //this acts as “slave select” DigitalIn switch_ip1(p5); DigitalIn switch_ip2(p6); char switch_word ; //word we will send char recd_val; //value return from slave //continued over Creating an SPI data link: Master 1 This program is written for the circuit shown. It declares a variable switch_word, the word that will be sent to the Slave, and the variable recd_val, which is the value received from the Slave.

23 int main() { while (1){ //Default settings for SPI Master chosen, no need for further configuration //Set up the word to be sent, by testing switch inputs switch_word=0xa0; //set up a recognisable output pattern if (switch_ip1==1) switch_word=switch_word|0x01; //OR in lsb if (switch_ip2==1) switch_word=switch_word|0x02; //OR in next lsb cs = 0; //select slave recd_val=ser_port.write(switch_word); //send switch_word and receive data cs = 1; wait(0.01); //set leds according to incoming word from slave red_led=0; //preset both to 0 green_led=0; recd_val=recd_val&0x03; //AND out unwanted bits if (recd_val==1) red_led=1; if (recd_val==2) green_led=1; if (recd_val==3){ red_led=1; green_led=1; } Creating an SPI data link: Master 2

24 FunctionsUsage SPISlaveCreate a SPI slave connected to the specified pins formatConfigure the data transmission format frequencySet the SPI bus clock frequency receivePolls the SPI to see if data has been received readRetrieve data from receive buffer as slave replyFill the transmission buffer with the value to be written out as slave on the next received message from the master. SPI on the mbed: Slave The Slave program (next slide) uses the mbed functions shown in the Table. It is almost the mirror image of the Master program, with small but key differences. It also declares variables switch_word and recd_val. The Slave program configures its switch_word just like the Master. While the Master initiates a transmission when it wishes, the Slave must wait. The mbed library does this with the receive( ) function. This returns 1 if data has been received, and 0 otherwise. If data has been received from the Master, then data has also been sent from Slave to Master.

25 /*Program Example 7.3: Sets the mbed up as Slave, and exchanges data with a Master, sending its own switch positions, and displaying those of the Master. as SPI slave. */ #include "mbed.h" SPISlave ser_port(p11,p12,p13,p14); // mosi, miso, sclk, ssel DigitalOut red_led(p25); //red led DigitalOut green_led(p26); //green led DigitalIn switch_ip1(p5); DigitalIn switch_ip2(p6); char switch_word ; //word we will send char recd_val; //value received from master int main() { //default formatting applied while(1) { //set up switch_word from switches that are pressed switch_word=0xa0; //set up a recognisable output pattern if (switch_ip1==1) switch_word=switch_word|0x01; if (switch_ip2==1) switch_word=switch_word|0x02; if(ser_port.receive()) { //test if data transfer has occurred recd_val = ser_port.read(); // Read byte from master ser_port.reply(switch_word); // Make this the next reply } //now set leds according to received word... (continues as in Program Example 7.2) Creating an SPI data link: Slave

26 The SPI standard is extremely effective. The electronic hardware is simple and therefore cheap, and data can be transferred rapidly. There are disadvantages. There is no acknowledgement from the receiver, so in a simple system the Master cannot be sure that data has been received. There is no addressing. In a system where there are multiple slaves, a separate |SS line must be run to each Slave, as seen earlier. Therefore we begin to lose the advantage that serial communications should give us, i.e. a limited number of interconnect lines. There is no error-checking. Suppose some electromagnetic interference was experienced in a long data link, data or clock would be corrupted, but the system would have no way of detecting this, or correcting for it. Overall SPI could be graded as: simple, convenient and low-cost, but not appropriate for complex or high reliability systems. Evaluating SPI

27 Assume the shift registers in the Master and Slave are 8-bit – each has 8 D-type flip-flops Each register is loaded with a new word via the parallel I/O lines The Master then produces 8 clock pulses. For each clock pulse, data is output from the msb of each register (SDO) Each SDO is connected to the lsb of the other shift register (SDI) As each bit is clocked out of one register, it is clocked into the other. After 8 clock cycles, the word that was in the master shift register as been transferred to the slave shift register, and vice versa. Master Shift Register Clock msb lsb Slave Shift Register msb lsb SDOSDI SDO SCLK Parallel Read/write SDO – serial data out SDI – serial data in SCLK – serial clock

28 SPI: Master-Slave Configuration Configuration master data output/slave data input (MOSI) master data input/slave data output (MISO) slave chip select (CS) – usually active low When multiple slave devices exist, the master must output a unique CS signal for each slave, but data lines can be shared. The programmer must know how data is timed between peripherals when shared.

29 SPI The master device starts an SPI data transfer by doing the following : Configures to SPI clock (SCLK) to be a frequency that the recipient slave device can handle (max is 70 MHz) Sets the chip select line (CS) of the intended recipient to 0 V Starts the clock pulses on SCLK to indicate that that data is to be transferred Simultaneously sends data as consecutive bits on MOSI Number of bits in each data frame can be configured, but is usually between 4 and 16 bits. The slave returns data in the same manner on MISO.

30 /* Sets up the mbed as SPI master, and continuously sends a single byte of data */ # include “mbed.h” SPI ser_part(p11, p12, p13); //mosi, miso, sclk char switch_word ; // word we will send int main() { ser_port.format(8,0); // Setup for 8 bit data, Mode 0 operation ser_port.frequency( ); // clock frequency is 1 MHz while (1){ switch_word=0xA1; //set up word to be transmitted ser_port.write(switch_word); //send switch_word wait_us(50); } SPI

31 CLK DATA A1

32 Disadvantages of Synchronous Serial Data Communication Synchronous serial communication protocols are extremely useful ways of moving data around. But taking a clock signal to every node does have these disadvantages: An extra (clock) line needs to go to every data node. The bandwidth needed for the clock is always twice the bandwidth needed for the data; therefore, it is the demands of the clock which limit the overall data rate. Over long distances, clock and data themselves could lose synchronisation.

33 Electronic Design Project The LED driver should be configured as the slave as it will only act on data sent from the microcontroller. You need to configure the data to be sent to the LED driver using the information provided in the LED driver datasheet.

34

35 Can You Answer These Questions? An SPI link is running with a 500 kHz clock. How long does it take for a single message containing one data byte to be transmitted? An mbed is to be set up as SPI Master, using pins 11, 12, and 13, running at a frequency of 4MHz, with 12-bit word length. The clock should idle at Logic 1, and data should be latched on its negative edge. Write the necessary code to set this up. You need to set up a serial network, which will have one Master and four Slaves. Every second, data has to be distributed, such that one byte is sent to Slave 1, four bytes are sent to Slave 2, three bytes are sent to Slave 3, and four bytes are sent to Slave 4. If the complete data transfer must take not more than 200 us, estimate the minimum clock frequency which is allowable for SPI. Assume there are no other timing overheads.


Download ppt "LOGIC FAMILIES. Logic Families Logic families are sets of chips that may implement different logical functions, but use the same type of transistors and."

Similar presentations


Ads by Google