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

Slides:



Advertisements
Similar presentations
Homework Reading Machine Projects Labs
Advertisements

Chapter 10 Input/Output Organization. Connections between a CPU and an I/O device Types of bus (Figure 10.1) –Address bus –Data bus –Control bus.
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
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.
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.
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.
Serial Communication Buses: I 2 C and SPI By Brody Dunn.
LCD programming Design and implementation details on the way to a valid SPI-LCD interface driver.
Serial Peripheral Interface (SPI)
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
Now we must send the correct signals over the MOSI line!!! 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.
INPUT-OUTPUT ORGANIZATION
SPI By Alexander Maroudis. Outline What is SPI? SPI Configuration SPI Operation Master Slave Setup SPI Transactions SPI Digital Potentiometer Example.
Computer Architecture Lecture 08 Fasih ur Rehman.
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.
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.
HD44780 LCD programming From the Hardware Side
LSU 10/22/2004Serial I/O1 Programming Unit, Lecture 5.
4.0 rtos implementation part II
DEVICES AND COMMUNICATION BUSES FOR DEVICES NETWORK–
MICROPROCESSOR INPUT/OUTPUT
Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN.
Lecture 20: Communications Lecturers: Professor John Devlin Mr Robert Ross.
(More) Interfacing concepts. Introduction Overview of I/O operations Programmed I/O – Standard I/O – Memory Mapped I/O Device synchronization Readings:
1 Synchronous Serial IO Send a separate clock line with data –SPI (serial peripheral interface) protocol –I 2 C (or I2C) protocol Encode a clock with data.
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
©2008 R. Gupta, UCSD COSMOS Summer 2008 Peripheral Interfaces Rajesh K. Gupta Computer Science and Engineering University of California, San Diego.
PPI-8255.
Essentials of Communication This simple model requires many guarantees. Sender Receiver Communication Link Data.
IT3002 Computer Architecture
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)
بسم الله الرحمن الرحيم MEMORY AND I/O.
SHIFT REGISTERS: CONVERTING BETWEEN SERIAL AND PARALLEL DATA Mark Neil - Microprocessor Course 1 Serial versus Parallel Data Transfers.
Embedded Systems February 10, Serial Interface - SPI  Serial Peripheral Interface  Synchronous communications  Clock supplied by the Master.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
“Lab. 5” – Updating Lab. 3 to use DMA Test we understand DMA by using some simple memory to memory DMA Make life more interesting, since hardware is involved,
Networked Embedded Systems Sachin Katti & Pengyu Zhang EE107 Spring 2016 Lecture 9 Serial Buses – SPI, I2C.
میکرو کنترلرهای AVR Serial Interfaces, I2C and SPI
1 Serial Peripheral Interface What is it? Basic SPI Capabilities Protocol Pros and Cons Uses Serial Peripheral Interface
Lab3 -- Lab 4 Design and implementation details on the way to a valid SPI-LCD interface driver.
Chapter 6 Input/Output Organization
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.
SERIAL PERIPHERAL INTERFACE
I2C PROTOCOL SPECIFICATION
SPI Compatible Devices
Asynchronous Serial Communications
SPI Compatible Devices
Преглед Начин функционисања Имплементације
SPI Compatible Devices
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
Lab3 -- Lab 4 Review Design and implementation details on the way to a valid SPI-LCD interface driver.
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

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 2 / 26 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?

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 3 / 26 What is SPI Serial Peripheral 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. DUPLEX MEANS – BOTH DIRECTIONS AT ONCE Master can receive from the slave at the same time as the master sends to the slave 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 -- LCD information --

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 4 / 26 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 / or absence. You could do “some” handshaking via software

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 5 / 26 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)

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 6 / 26 Concept of Master and Slave Master The component that initiates the transfer The component that controls the transfer Slave The component that responds to the transfer

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 7 / 26 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 FOR SAFETY – SELECT SIGNAL IS “ACTIVE LOW” NOT “ACTIVE HIGH”

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 8 / 26 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

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 9 / 26 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

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 10 / 26 Lab. 4 concept – Using an SPI interface to an LCD screen SPI_TDBR Blackfin Processor SPI_RXBR LCD SCREEN CJ7 / CJ8 SWITCHES (LOGIC LAB) SLAVE INPUT INTERFACE SLAVE OUTPUT INTERFACE MOSIMISO SLAVE SELECT PF5 used (PF0 to PF7) DATA CONTROL SPI CLOCK LOAD Slave to LCD

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 11 / 26 Lab. 4 interface From Blackfin SPI lines (MOSI, CLK, PF5) GET PIN ORDER CORRECT OR NOTHING WORKS

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 12 / 26 Lab Essentials (concept) of the Blackfin – LCD interface software char HipHipArray[ ] = “Merry Christmas to all”; SetUp_SPI_Interface(Baud_Rate); // Configure the SPI interface // Activate SPI interrupts – register_handler for SPI_ISR, set SIC_IMASK LCD_Display (WHICH_LCD, “CONTROL”, “CLEAR_SCREEN”); UseFixedTimeASM(Enough_Time_For _LCD_To_Work_ClearScreen); for (int count = 0; count < strlen(HipHipArray); count++) { LCD_Display (WHICH_LCD, “DATA”, HipHipArray[count]); // Transmit the information we want from the array // one character at a time UseFixedTimeASM(Enough_Time_For _LCD_To_Work_DataSent); }

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 13 / 26 LCD_Display (int, char*, char *); Concept – not actual implementation LCD_Display (int lcd, char * type, char *operation) { if (strcmp(type, “COMMAND”) == 0) { if (strcmp(operation, “CLEAR_SCREEN”) == 0) ClearScreen( ); if (strcmp(operation, “……..”) == 0) Do……..( ); } if (strcmp(type, “DATA”) == 0) { if (strcmp(operation, “DISPLAY_TEMPERATURE”) == 0) DisplayTemperatureOnLCD( ); // Recursive call to LCD_Display else WriteLetter(operation[0]); // First character }

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 14 / 26 Example Commands Could we send commands like this? char *LCDcommands[ ] = { "COMMAND", "INIT_LCD", "COMMAND", "CLEAR_SCREEN", "COMMAND", "MOVE_TO_LINE_1", "COMMAND", "CLEAR_LINE_1", "DATA", "4", // This number is a 2 character string '4' and '\0' "DATA", "1", // This number is a 2 character string '1' and '\0' "DATA", "5", // This number is a 2 character string '5' and '\0' "COMMAND", "MOVE_TO_LINE_2", "COMMAND", "CLEAR_LINE_2", "DATA", "TEMPERATURE_DISPLAY" NULL, NULL};

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 15 / 26 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?

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 16 / 26 What about the voltages that must go to the LCD? Discussed those in the last lecture

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 17 / 26 LCD Instruction set

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 18 / 26 0 through 9, ( ) etc – all the same?

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 19 / 26 Is this a possible solution? Writing “Hello” to the LCD ClearScreen( ); UseFixedTimeASM( ); CursorIncrease( ); UseFixedTimeASM( ); DisplayOn( ); Use FixedTimeASM( ); WriteLetter(‘H’); UseFixedTimeASM( ); CursorMove( ); UseFixedTimeASM( ); 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? If you send CursorMove( ) and wait too long -- do you get two cursor moves? If so – how do you stop that from happening?

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 20 / 26 Where does Blackfin fit in? ClearScreen( ); 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 parallel interface Possible solution -- Let us send out a ushort value 0x0001 from the Blackfin and arrange the wires from the interface to go to the LCD connections correctly Top 8 bits of unsigned short value – LCD control Bottom 8 bits of unsigned short value – LCD data Page 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.

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 21 / 26 Blackfin transmits 16 bits with THIS format over the MOSI line DB7, DB6, ………DB1, DB0 RS 1 – LCD data 0 – LCD instruction R/W 1 – Read from LCD 0 – Write to LCD E – Enable / Strobe 1  0 – When this line goes from high to the low, then the command is send to (latched into) LCD To make LCD respond to command 0x4F0 Then Blackfin must transmit 0x5F0 ( E High ) 0x4F0 ( E low ) 0x5F0 ( E high )

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 22 / 26 Is this a possible solution? Insert into ClearScreenASM( ) stub Initialize the SPI interface in main( ) P0.L = lo(SPI_TDBR) – SPI transmit data buffer register P0.H = hi(SPI_TDBR) R0 = 0x0001;// LCD ClearScreen instruction [P0] = R0;  Not correct – TDBR is 16-bit R0 = some_value; Call UseFixedTimeASM; // Wait for LCD to be done

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 23 / 26 Is this a POSSIBLE solution? WriteLetterASM(char whichletter) P0.L = lo(SPI_TDBR) – SPI transmit data buffer register P0.H = hi(SPI_TDBR) R1 = 0x400; // Write data instruction // Need to make line RS = 1 for data 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

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 24 / 26 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 Could be a problem if we “wait too long”. Perhaps multiple commands get sent to the LCD screen We know the answer to the last question from the last lecture Set the command with the EN bit high Send the command with the EN bit low // Data goes into LCD on transition HI / LOW of EN-Bit Send the command with the EN-bit high

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 25 / 26 Code MIGHT look like this then WriteLetterASM(char whichletter) Save registers R7 and P5 properly to stack (how?) P5.L = lo(SPI_TDBR) P5.H = hi(SPI_TDBR) R7 = R0; // which letter came in R0 R1 = 0x500; // Write data instruction // Need to make line RS = 1 for data and E = 1 R7 = R7 | R1; W[P5] = R7; // Send data and control to LCD device R0 = some_longer_value; Call UseFixedTimeASM; // Wait for LCD to complete command R1 = ~0x100 // Remove the E signal R7 = R7 & R1 W[P5] = R7 R0 = some_longer_value; Call UseFixedTimeASM; // Wait for LCD to complete command Now add back the E-signal and store into W[P5] again

8/14/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 26 / 26 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?