SPI Compatible Devices

Slides:



Advertisements
Similar presentations
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
Advertisements

Serial Interfaces, Part Deux -I 2 C and SPI December 4, 2002 Presented by Eugene Ho.
SPI Serial Peripheral Interface. SPI Serial Peripheral Interface is communication between two devices, one bit at a time sequential one bit at time over.
Lecture 8: Serial Interfaces
Lab3 -- Lab 4 Design and implementation details on the way to a valid SPI-LCD interface driver.
Peripherals and their Control An overview of industrially available “peripheral devices” Some ideas for Laboratories and Quiz / Exam questions.
6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 1 Temperature Sensor Laboratory 2 Part 2 – Developing.
If we can just send 1 signal correctly over the MOSI line!!! Design and implementation details on the way to a valid SPI-LCD interface driver.
Thermal arm-wrestling Design of a video game using two programmable flags (PF) interrupts Tutorial on handling 2 Hardware interrupts from an external device.
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
Blackfin SPI Compatible Interface Design and implementation details on the way to a valid SPI-LCD interface driver.
HD44780 LCD programming From the Hardware Side Design and implementation details on the way to a valid SPI-LCD interface driver.
LCD programming Design and implementation details on the way to a valid SPI-LCD interface driver.
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
SPI Compatible Devices Design and implementation details on the way to a valid SPI-LCD interface driver.
SPI By Alexander Maroudis. Outline What is SPI? SPI Configuration SPI Operation Master Slave Setup SPI Transactions SPI Digital Potentiometer Example.
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.
HD44780 LCD programming From the Hardware Side
LSU 10/22/2004Serial I/O1 Programming Unit, Lecture 5.
4.0 rtos implementation part II
Lecture 20: Communications Lecturers: Professor John Devlin Mr Robert Ross.
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
Department of Electronic & Electrical Engineering LCD character display (parallel interface). How to interface a LCD character display to a PIC.
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)
Networked Embedded Systems Sachin Katti & Pengyu Zhang EE107 Spring 2016 Lecture 9 Serial Buses – SPI, I2C.
Computer Organization
Lab3 -- Lab 4 Design and implementation details on the way to a valid SPI-LCD interface driver.
Chapter 6 Input/Output Organization
Serial mode of data transfer
Serial Communication Buses: I2C and SPI
EE 107 Fall 2017 Lecture 5 Serial Buses – UART & SPI
Lab3 -- Lab 4 Design and implementation details on the way to a valid SPI-LCD interface driver.
1 Input-Output Organization Computer Organization Computer Architectures Lab Peripheral Devices Input-Output Interface Asynchronous Data Transfer Modes.
SERIAL PERIPHERAL INTERFACE
Programming Microcontroller
Atmega32 Serial Programming Basics
I2C PROTOCOL SPECIFICATION
Developing a bicycle speed-o-meter
EEPROM Comparison – Parallel or Serial
SPI Compatible Devices
Introduction to Microprocessors and Microcontrollers
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
Thermal arm-wrestling
DMA example Video image manipulation
The planned and expected
Преглед Начин функционисања Имплементације
SPI Compatible Devices
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
Moving Arrays -- 2 Completion of ideas needed for a general and complete program Final concepts needed for Final DMA.
Thermal arm-wrestling
Using Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Moving Arrays -- 2 Completion of ideas needed for a general and complete program Final concepts needed for Final DMA.
HD44780 LCD programming From the Hardware Side
HD44780 LCD programming From the Hardware Side
Expand on these ideas for Q9 question and answer on the final
Thermal arm-wrestling
Concept of TDD Test Driven Development
Lab3 -- Lab 4 Review Design and implementation details on the way to a valid SPI-LCD interface driver.
DMA example Video image manipulation
Developing a bicycle speed-o-meter
Independent timers build into the processor
Developing a bicycle speed-o-meter
Developing a bicycle speed-o-meter
Thermal arm-wrestling
Developing a reliable communication between Blackfin and Slave device
Lab3 -- Lab 4 Design and implementation details on the way to a valid SPI-LCD interface driver.
Serial Peripheral Interface Bus
Chapter 13: I/O Systems.
Presentation transcript:

SPI Compatible Devices Design and implementation details on the way to a valid SPI-LCD interface driver

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada To be tackled today What is SPI? What is the SPI “master slave” relationship? How do you send commands from the Blackfin to a LCD device? What commands are necessary to control the LCD device -- HD44780? 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada What is SPI Serial Parallel Interface – an industry standard SPI is a serial communication bus developed by Motorola. It is a full-duplex protocol that functions on a master-slave paradigm that is ideally suited to data stream application. Is essentially a 4 wire high speed system, with speeds up to many MHz Blackfin (p10-8) has a register SPI_BAUD where they talk about transfer rates of 25 MHz. Information is précised from SPI information -- http://www.totalphase.com/docs/articles/article03/ LCD information -- http://home.iae.nl/users/pouweha/lcd/lcd.shtml 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

Advantages and drawbacks SPI is a very simple communication protocol. It does not have a specific high-level protocol which means that there is almost no overhead. Data can be shifted at very high rates in full duplex mode This makes it very simple and efficient in a single master single slave scenario. The exchange itself has no pre-defined protocol. This makes it ideal for data-streaming applications. Data can be transferred at high speed, often into the range of the tens of megaHertz. The flipside is that there is no acknowledgment, no flow control, and the master may not even be aware of the slave's presence. 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada Systems that use SPI The question is of course, which peripheral types exist and which can be connected to the host processor. Peripheral types can be subdivided into the following categories: Converters (ADC and DAC) Memories (EEPROM and FLASH) Real Time Clocks (RTC) Sensors (temperature, pressure) Others (signalmixer, potentiometer, LCD controller, UART, CAN controller, USB controller, amplifier) 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

Concept of Master and Slave The component that initiates the transfer The component that controls the transfer Slave The component that responds to the transfer 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

Master / Slave concept Slave Select (Chip Select) Master sends out active low chip select signal SS1, then slave 1 responds Master sends out active low chip select signal SS2, then slave 2 responds 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

Master / Slave concept Master to Slave data movement Master sends out information to slave on MOSI wire Slave receives information from the master on MOSI wire Information (bits) is clocked by SCLK signal. 1-bit, 1 clock tick MOSI --MASTER OUT – SLAVE IN 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

Master / Slave concept Slave to Master data movement Master receives information from slave on MISO wire Slave sends information to the master on MISO wire Information (bits) is clocked by SCLK signal. 1-bit, 1 clock tick MISO --MASTER IN – SLAVE OUT 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

Lab. 5 concept – Using an SPI interface to an LCD screen Blackfin Processor SLAVE SELECT PF5 used (PF0 to PF7) SPI CLOCK MOSI MISO SLAVE OUTPUT INTERFACE SLAVE INPUT INTERFACE LOAD Slave to LCD DATA SWITCHES (LOGIC LAB) CONTROL LCD SCREEN 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada Lab. 5 interface From Blackfin 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

Lab. 5 Essentials of the Blackfin – LCD interface software char HipHipArray[ ] = “Merry Christmas to all”; SetUp_SPI_Interface(Baud_Rate); // Configure the SPI interface LCD (CONTROL_REQUEST, CLEAR_SCREEN); for (int count = 0; count < strlen(HipHipArray); count++) { LCD (DATA_REQUEST, HipHipArray[count]); // Transmit the information we want UseFixedTimeASM(Enough_Time_For _LCD_To_Work); } 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada What we need to know? How do we make the LCD screen respond to control requests? Clear screen, move cursor, next line etc How do we make the LCD screen respond to data requests? Display letter a, b, C, 1, 2, (, ?, h etc How do we get Blackfin SPI interface to send the LCD screen those commands? How to we initialize the Blackfin SPI interface so all the above things work? 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

What about the voltages that must go to the LCD? 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada LCD Instruction set 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

Details of what is needed 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

Data to send a character Complicated or not? To cause “A” to appear on LCD screen need bit pattern 01000001 = 0x41 sent to LCD data pins Also send the necessary LCD control signals How do the letter bit patterns for the LCD data patterns relate to ASCII bit patterns? standard format used to store characters in a C++ character array? 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

A to Z, a to z Coding exactly the same? 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

0 through 9, ( ) etc – all the same? 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada Some commands LCD COMMANDS RS R/W DATA DB7 to DB0 ClearScreen( ) 0x01 CursorIncrease( ) 0x05 CursorMove( ) 0x10 DisplayOn( ) 0x0B WriteLetter(value) 1 value WriteLetter(‘a’) 0x61 (ascii ‘a’) WriteLetter(‘A’) 0x41 (ascii ‘A’) 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

Is this a possible solution? Writing “Hello” to the LCD ClearDisplay( ); UseFixedTimeASM( ); CursorIncrease( ); UseFixedTimeASM( ); DisplayOn( ); Use FixedTimeASM( ); WriteLetter(‘H’); CursorMove( ); WriteLetter(‘e’); etc. General concept is there, The exact details will have to wait a while QUESTION! What happens if you send a CursorMove( ) command and wait too long? Do you get two cursor moves? If so – how do you stop that from happening? 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

Where does Blackfin fit in? ClearDisplay( ); This means that the following bits must be sent RS = 0, R/W = 0, DB7=DB6=DB5….DB1 = 0, DB0 = 1; from Blackfin SPI interface to LCD Possible solution -- Let us send out the ushort value 0x0001 from the Blackfin and arrange the wires from the interface to go to the LCD connections correctly Top 8 bits of ushort value – LCD control Bottom 8 bits of ushort value – LCD data Page 10-17 -- SPI Transmit Data Buffer Register SPI_TDBR – 16-bit read/write register. Data loaded into this data register is automatically transmitted over the SPI interface if the SPI interface is enabled for transmission. 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

Is this a possible solution? ClearDisplayASM( ) Initialize the SPI interface in main( ) P0  SPI_TDBR – SPI transmit data buffer register R0 = 0x0001; // LCD instruction [P0] = R0;  Not correct – TDBR is 16-bit R0 = some_value; Call UseFixedTimeASM; 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

Is this a better solution? WriteLetterASM(char whichletter) P0  SPI_TDBR – SPI transmit data buffer register R1 = 0x200; // Write data instruction R0 = R0 | R1; // R0 contains 8-bit letter W[P0] = R0; // Send data and control // to LCD device R0 = some_longer_value; Call UseFixedTimeASM; // Wait for // LCD 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

Is this a better version? WriteLetterASM(char whichletter) P0  SPI_TDBR – SPI transmit data buffer register R1 = 0x200; // Write data instruction R0 = R0 | R1; W[P0] = R0; R0 = some_longer_value; Call UseFixedTimeASM; Call CursorMove; // Get ready for next 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

Questions still unanswered How do we configure the SPI interface inside the Blackfin? How do we activate the chip-select line – PF5? Does activating the PF5 line as SPI output control mean we have to change all the SetupPF8to11ASM( ) and other routines? When do we activate the chip-select line, and how long for? How do we know when LCD is ready for next character – do we poll a bit and wait till ready, or can it be done in the background? How do we stop multiple commands from being accidentally sent to LCD? -- cursor move etc 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada Tackled today What is SPI? What is the SPI “master slave” relationship? How do you send commands from the Blackfin to a LCD device? What commands are necessary to control the LCD device -- HD44780? 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada

SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada Information taken from Analog Devices On-line Manuals with permission http://www.analog.com/processors/resources/technicalLibrary/manuals/ Information furnished by Analog Devices is believed to be accurate and reliable. However, Analog Devices assumes no responsibility for its use or for any infringement of any patent other rights of any third party which may result from its use. No license is granted by implication or otherwise under any patent or patent right of Analog Devices. Copyright  Analog Devices, Inc. All rights reserved. 11/28/2018 SPI and LCD , Copyright M. Smith, ECE, University of Calgary, Canada