ELE22MIC Lecture 11 Serial Peripheral Interface - SPI AS11 PAL/PLD

Slides:



Advertisements
Similar presentations
Computer Architecture
Advertisements

8086 [2] Ahad. Internal! External? 8086 vs _bit Data Bus 20_bit Address 8_bit Data Bus 20_bit Address Only external bus of 8088 is.
Anurag Dwivedi Rudra Pratap Suman. Scope of Communica tion Telephones and Cell Phones.
PROGRAMMABLE PERIPHERAL INTERFACE -8255
EXTERNAL COMMUNICATIONS DESIGNING AN EXTERNAL 3 BYTE INTERFACE Mark Neil - Microprocessor Course 1 External Memory & I/O.
Programmable Interval Timer
SCI: Serial Communications Interface Presented by: Sean Kline Chad Smith Jamie Cruce.
TK2633 Introduction to Parallel Data Interfacing DR MASRI AYOB.
82C55 82C55 Programmable Peripheral Interface Interfacing Part III.
The 8085 Microprocessor Architecture
Microprocessor and Microcontroller
Processor System Architecture
SHIFT REGISTERS: CONVERTING BETWEEN SERIAL AND PARALLEL DATA Mark Neil - Microprocessor Course 1 Serial versus Parallel Data Transfers.
Serial Interfaces, Part Deux -I 2 C and SPI December 4, 2002 Presented by Eugene Ho.
68HC11 Polling and Interrupts
Serial Communication Buses: I 2 C and SPI By Brody Dunn.
Guitar Effects Processor Critical Design Review October, 07, 2003 Groups Members: Adam Bernstein Hosam Ghaith Jasenko Alagic Matthew Iyer Yousef Alyousef.
Serial Peripheral Interface (SPI)
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
7-1 Digital Serial Input/Output Two basic approaches  Synchronous shared common clock signal all devices synchronised with the shared clock signal data.
Configuration. Mirjana Stojanovic Process of loading bitstream of a design into the configuration memory. Bitstream is the transmission.
GURSHARAN SINGH TATLA PIN DIAGRAM OF 8085 GURSHARAN SINGH TATLA
INPUT-OUTPUT ORGANIZATION
Serial Peripheral Interface (SPI) Bus. SPI Bus There is no official specification for the SPI bus. It is necessary to consult the data sheets of the devices.
Serial Peripheral Interface Module MTT M SERIAL PERIPHERAL INTERFACE (SPI)
ECE 265 – LECTURE 12 The Hardware Interface 8/22/ ECE265.
Khaled A. Al-Utaibi  Intel Peripheral Controller Chips  Basic Description of the 8255  Pin Configuration of the 8255  Block Diagram.
CRKit RF Control WINLAB – Rutgers University Date : June Authors : Prasanthi Maddala, Khanh Le,
CRKit RF Control WINLAB – Rutgers University Date : June Authors : Prasanthi Maddala, Khanh Le,
CRKit RF Control WINLAB – Rutgers University Date : June Authors : Prasanthi Maddala, Khanh Le,
Chapter 10: Input / Output Devices Dr Mohamed Menacer Taibah University
CRKit RF Control WINLAB – Rutgers University Date : June Authors : Prasanthi Maddala, Khanh Le,
7/23 Inter-chip Serial Communication: SPI and I 2 C Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee.
Dr. Rabie A. Ramadan Al-Azhar University Lecture 6
Volume. 1-the idea of the program is to increase, decrease the volume. 2-the program does the following: A-PF8:decrease the volume B-Pf9:increase the.
The 8253 Programmable Interval Timer
By, Prof. Tambe S. S. S.N.D. College of Engineering and Research Center Department of Electrical Engineering.
Universal Synchronous/Asynchronous Receiver/Transmitter (USART)
Lecture 20: Communications Lecturers: Professor John Devlin Mr Robert Ross.
Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 2.
Advanced Microprocessor1 I/O Interface Programmable Interval Timer: 8254 Three independent 16-bit programmable counters (timers). Each capable in counting.
 8251A is a USART (Universal Synchronous Asynchronous Receiver Transmitter) for serial data communication.  Programmable peripheral designed for synchronous.
Direct Memory Access (DMA) Microprocessors I -1. Topics to be discussed  Basic DMA Concept Basic DMA Concept  DMA pins and timing DMA pins and timing.
ELE22MIC Lecture 9 MULTIPLEXOR - DATA SELECTOR DEMULTIPLEXOR - DATA DISTRIBUTOR Parallel to Serial Data Conversion External Address Bus Latching Address.
ELE22MIC Lecture 10 MULTIPLEXOR - DATA SELECTOR
1 October 26, 2006ME 6405 MechatronicsSerial Communication Interface Brian Guerriero Jon Rogers Robert Thiets.
12/16/  List the elements of 8255A Programmable Peripheral Interface (PPI)  Explain its various operating modes  Develop a simple program to.
OCRP RF Control WINLAB – Rutgers University Date : June Authors : Prasanthi Maddala, Khanh Le,
EFLAG Register of The The only new flag bit is the AC alignment check, used to indicate that the microprocessor has accessed a word at an odd.
OCRP RF Control WINLAB – Rutgers University Date : June Authors : Prasanthi Maddala, Khanh Le,
Parallel I/O. Introduction This section focuses on performing parallel input and output operations on the 68HC11 3 operation types – Simple, blind data.
Department of Electronic & Electrical Engineering Serial interfaces Serial Interfaces allow communication between devices sending one bit at a time. In.
Serial Peripheral Interface SPI I2C (i-squared cee)
1 Expanded Modes, Bus, External Memory Today: First Hour: Expanded Modes, Bus, Timing –Section of Huang’s Textbook –In-class Activity #1 Second.
بسم الله الرحمن الرحيم MEMORY AND I/O.
SHIFT REGISTERS: CONVERTING BETWEEN SERIAL AND PARALLEL DATA Mark Neil - Microprocessor Course 1 Serial versus Parallel Data Transfers.
Communicating. The ATmega16 communicates through one of the following ways: Serial Peripheral Interface (SPI) Universal Synchronous and Asynchronous serial.
Chapter 3. Advanced Hardware Fundamentals The various parts you will commonly find in an embedded-system circuit 발표일시 : 발표자 : 채화영.
BIRLA VISHVAKARMA MAHAVIDYALAY SUBJECT: SPI PROTOCOL & MAX7221 DISPLAY INTERFACING SUBMITTED BY: KISHAN AVASTHI( ) MANSI CHANDEGARA( )
8251 USART.
Fundamentals of Computer Engineering
Tutorial Introduction
General Purpose I/O.
SERIAL PERIPHERAL INTERFACE
EEPROM Comparison – Parallel or Serial
Serial Communication Interface: Using 8251
Parallel communication interface 8255
SPI Protocol and DAC Interfacing
SPI Protocol Sepehr Naimi
Hardware Source: ttp:// under
Presentation transcript:

ELE22MIC Lecture 11 Serial Peripheral Interface - SPI AS11 PAL/PLD technology 68HC11 program AS11 getting as11 running options PAL/PLD Technology & Programming

Parallel I/O

Serial Peripheral Interface (SPI 1)

Serial Peripheral Interface (SPI 2) During an SPI transfer, data is simultaneously transmitted (shifted out serially) and received (shifted in serially). A serial clock line synchronises shifting and sampling of the information on the two serial data lines. A slave select line allows individual selection of a slave SPI device; slave devices that are not selected do not interfere with SPI bus activities. On a master SPI device, the slave select line can optionally be used to indicate a multiple-master bus contention.

Serial Peripheral Interface (SPI 3) Simplest Form: The SPI can be used to add an extra 8 bit output port using an 8-bit shifter and latches. Master Out Slave In MOSI (Serial Data) -> Pin14 (MS bit sent first) Clock ->Pin 11 SS# = Pin 12 = Low during transmission Reset# = Pin 10 = 5V OE# = Pin 13 = 0V

Serial Peripheral Interface (SPI 4) Configuring SPI - From Technical Data 11A8TD.pdf, P29.

Serial Peripheral Interface (SPI 5) Four major registers influence SPI usage: 1. SPI Control Register (SPCR at $1028), 2. SPI Status Register (SPSR at $1029), and 3. SPI Data Register (SPDR at $102A) 4. Data Direction Register for port D (DDRD at $1009) These are software-accessible registers used to configure and operate the SPI system. Detailed logic diagrams of the port D pins can be found in 68HC11 Reference Manual SECTION 7 PARALLEL INPUT/OUTPUT (ELE22MIC cdrom:\MotorolaDatasheets\11rm.pdf)

Serial Peripheral Interface (SPI 6) Transfer Format: Data Out is Clocked with Rising SCK , when CPOL = 0 (CPOL = BIT3 of SPI Control Register (SPCR)

Serial Peripheral Interface (SPI 7) SCK Bit Rate Select when 68HC11 is selected as Master is defined by SPR1 & SPR0 from SPCR

Serial Peripheral Interface (SPI 8) Data Direction Register D (DDRD) - This register, which may be read or written at any time, is used to control the primary direction of port D pins. Bits 5, 4, 3, and 2 of port D are used by the SPI system when the SPI Enable (SPE) control bit is one. The Serial Communications Interface (SCI) system uses the other two bits of port D when the SCI receiver and transmitter are enabled. This description of DDRD is only intended to cover material related to the SPI system.

Serial Peripheral Interface (SPI 9) Data Direction Register D (DDRD) - DDRD5 — Data Direction Control for Port D Bit 5 (SS) When the SPI system is enabled as a master (SPE = 1; MSTR = 1), the function of the PD5/SS pin depends on the value in DDRD5. When the SPI system is enabled as a slave (SPE = 1; MSTR = 0), the PD5/SS pin is the slave select input, regardless of the value of DDRD5. See also Section 8.5.1 SPI Mode-Fault Error - Upon detection of mode error, all SPI pins are set to inputs.

Serial Peripheral Interface (SPI 10) Data Direction Register D (DDRD) - DDRD4 — Data Direction Control for Port D Bit 4 (SCK) When the SPI system is enabled as a master, the DDRD4 bit must be set to one to enable the SCK as an output. When the SPI system is enabled as a slave, the PD4/SCK pin acts as the SPI serial clock input, regardless of the state of DDRD4.

Serial Peripheral Interface (SPI 11) SPI Master-Slave Interconnection Notes: Master generates SPI clock, SS - Slave Select - is hard-wired low for slave Image from 68HC11A8 Technical Data (11atd.pdf)

SPI Write Assembly Code (SPI CODE 1) ACCESS_SPI: LDAA #50 ; 0101 00002 ; BIT7 = 0 = SPIE = Interrupts Disabled ; BIT6 = 1 = SPE = SPI System Enabled ; BIT5 = 0 = DWOM = outputs are push-pull ; 1 = DWOM = Port D Wired OR Mode ; BIT4 = 1 = MSTR = SPI MaSTeR Mode Select ; BIT3 = 0 = CPOL = Clock Polarity Select ; BIT2 = 0 = CPHA = Clock Phase Select ; BIT1/0= 0,0 = Bit Rate Select = E Clk / 2 STAA 1028 ; SPI Control Register (SPCR) * If CPHA = 0, SS# must be toggled every 8 bits. * If CPHA = 1, SS# may remain active-low between 8 bit transfers. * This is useful for sending multi-bytes transfers

SPI Write Assembly Code (SPI CODE 2) * Configure the port D Pins used for SPI LDAA #38 ; 0011 10002 ; BIT7 & 6 = 0, 0 = Unused Bits - Don’t exist on port D ; BIT5 = 1 = Configure for output SS# ; BIT4 = 1 = Configure for output SCLK ; BIT3 = 1 = Configure for Output MOSI ; BIT2 = 0 = Configure for Input MISO ; BIT1 = 0 = SCI Transmit Data = TxD ; BIT0 = 0 = SCI Receive Data = RxD STAA 1009 ; DDRD - Data Direction Register for Port D

SPI Write Assembly Code (SPI CODE 3) LDAA #55 ; 0101 01012 - Data to send to SPI Slave STAA 102A ; SPI Data Register = SPDR PollAgain: LDAB 1029 ; Read SPI Status Register = SPSR ; Acc B = Status of SPI ; BIT7 = SPIF = 1 => SPI Transfer is Complete ; BIT6 = 1 => WCOL = SPI Write Collision ; Write to data register while transfer is taking place ; BIT4 = MODF = SPI Mode Fault, Normally 0 ; Set to 1 = Multi Master Conflict -> Disables SPI ; Bits 5, 3-0 always return 0. BITB #80 ; AND SPIF bit - Transfer Complete? BEQ PollAgain ; If still 0, keep waiting. ; could use: ; PollAgain: ; …. ; BRCLR 1029, PollAgain

SPI Write Assembly Code (SPI CODE 4) BCLR $1008 20 ; 1008 = Port D = Strobe Bit 5 Low = SS BSET $1008 20 ; 1008 = Port D = Strobe Bit 5 High = SS * We have sent byte via SPI, now return to the calling routine RTS ; Return from Subroutine

Instruction Cycle times Different instructions take varying lengths of time. Sometimes this is important to know exactly how long a section of will take to execute. This can be calculated by looking up the number of cycles each instruction takes, and adding them together. Another way is to get the assembler to list them for you.

Example Assembler org 2000 ; Uses: = N, CCR NSomethings: ; RepeatAgain: ; repeat { JSR DoSomething ; { DoSomething () // do it A times DEC N ; N--; ; } BNE RepeatAgain ; until (N == 0) ExitLoop: RTS org 2100 N RMB 1 ; RMB = Reserve Memory Byte

Getting AS11 To get AS11 visit the URL: http://thor.ee.latrobe.edu.au/~paulm/ele22mic/index.html at the bottom of the page, right click on the link AS11 Assembler and select “Save Target As” to a local directory d:\as11 for example. Also available from your ELE22MIC CDROM / textbook CDROM.

AS11 Assembler Invocation To invoke the cross-assembler AS11 in a dos box enter: AS11 file1 (file2...) -option1 -option2 Options: l enable output listing. nol disable output listing (default). cre generate cross reference table. s generate a symbol table. c enable cycle count. noc disable cycle count.

Schematic vs PAL Diagram

PLD Technology (1) Equations can be written to describe the required logic arrangement. Next the equations can be compiled to produce a JEDEC file, and then loaded into the PAL using a device programmer. In the event that an error in logic was made, re-programming the PLD can correct the design error without modifying the Printed Circuit Board.

PLD Technology (2)

PLD Technology (3)

PLD Technology (4) The 22V10 Programmable Logic Device (PLDs) is a popular choice to generate necessary glue logic for microprocessor designs. By using one programmable device designers can save on many other Small Scale Integration devices, and also save power. PLDs can be based on EPROM, EEPROM or FLASH technology.

Configuring a PAL/PLD (1) Programmable Array Logic (PALs) or Programmable Logic Devices (PLDs) can be configured by setting / resetting “fuse” links. There are many logic device families and programming languages for example: For PALs: PALASM, CUPL, or Schematic Entry For FPGAs: Varilog, VHDL, ABLE, Schematic Protel’s Advanced PLD allows you to design using logic in a schematic, or the CUPL/VHDL language, and then compile to a JEDEC, ready to program into a PLD

CUPL Template

Example CUPL Program (1) Name AddressDecode14; Partno MV12C; Revision 03; Date 19 June, 2001; Designer Paul Main; Company Systems Engineering Arts Pty Ltd; Assembly MV12C03 -> PC104 Modem Control lines; Location U1; Device G20V8; /************************************************************************/ /* Commercial Prototype */ /* This device decodes the PC104 address bus and generates enable */ /* signals for the serial port, the tone detector port & Control Reg. */ /* The base address is set at 2E0..2EF. */ /* CardSelect is determined by comparing 8 bits, A10-A3 of the PC104 bus*/ /* with 2Ex. (8 addresses will fold from 2E0..2E7 to 2E8..2EF) */ /* When the address matches and address enable (AEN) is low then */ /* Card Select signal is generated. */ /* Address bits PA2..PA0 are used to select which port: */ /* DetectorRead = CardSelect & (PA2 = 1 & PA1 = 1 & PA0 = 1) */ /* ModemSelect = CardSelect & (PA2 = 1 | PA1 = 1 | PA0 = 1) */ /* DetectIOR /* */ /* Allowable Target Device Types: PALCE20V8 */

Example CUPL Program (2) /** Inputs **/ pin 1 = !aen ; /* PC's address enable strobe */ pin [2..11,13] = [sa10..0] ; /* system address pins sa0 - sa10 */ pin 17 = !IOW ; /* IO Write strobe */ pin 18 = !IOR ; /* IO Read Strobe */ /** Outputs **/ pin 19 = !ModemRead ; /* modem read enable */ pin 20 = !ModemSelect ; /* modem select for read or write */ pin 21 = DetWrite ; /* 74HC374 is Rising edge triggered */ pin 22 = !DetRead ; /* tone detector port */ pin 16 = CardAddr ; /* The card is selected - modem or detectors */ /** Declarations and Intermediate Variable Definitions **/ field CardAddress = [sa10..0] ; /** Logic Equations **/ CardAddr = CardAddress:[2E0..2Ef] ; /* select modem for io addr 2e8 to 2ef */ ModemSelect= CardAddr & sa3 & aen ; /* Modem Buffer read/write control */ ModemRead = ModemSelect & IOR ; /* Modem Buffer read/write control */ DetWrite = CardAddr & !sa3 & aen & IOW ; /* Detector latch is selected on write to i/o address 2e0.. */ DetRead = CardAddr & !sa3 & aen & IOR ; /* Detector buffer is selected on read from i/o address 2e0.. */

Example JEDEC (1) ADVANCED PLD 4.0 Serial# MW-67999999 Device g20v8ma Library DLIB-h-36-3 Created Mon Aug 25 19:09:47 2003 Name AddressDecode14 Partno MV12C Revision 03 Date 19 June, 2001 Designer Paul Main Company Systems Engineering Arts Pty Ltd Assembly MV12C03 -> PC104 Modem Control lines Location U1 *QP24 *QF2706 *G0 *F0 *L00000 11111111111111111111111111111111 *L00032 11111111111011111111111111111110

Example JEDEC (1) *L00064 11111001111111110000000000000000 *L00320 11111111111111111111111111111111 *L00352 11111111111011111111111111111111 *L00384 11101001111111110000000000000000 *L00640 11111111111111111111111111111111 *L00672 11111111111011111111111111111111 *L00704 11110101111111110000000000000000 *L00960 11111111111111111111111111111111 *L00992 11111111111111111111111011111110 *L01024 11111111111111110000000000000000 *L01920 11111111111111111111111111111111 *L01952 11111111101101111011011101110111 *L01984 10111111111111110000000000000000 *L02560 01000010010011010101011000110001 *L02592 00110010010000110000000000000000 *L02624 00000000111111111111111111111111 *L02656 11111111111111111111111111111111 *L02688 111111111111111111 *C3AD9 *02C5

Programming the PLD

PLD in Circuit The chip select lines are now decoded for the four output terms: Pin 22= DetEnableRd#, Pin 21 = DetEnableWr#, Pin 20 = ModemSelect#, Pin 19 = ModemRead# Pin 16 = TP3 = CardAddr Top: 20V8 PAL Middle: Logic Container Bottom: PC104 bus interface

Acknowledgements I used Altium Protel 98 and Protel DXP to create these schematic diagrams Motorola 68HC11 Reference Manual (11rm.pdf ) Motorola 68HC11A8 Technical Data (11a8td.pdf )