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

Slides:



Advertisements
Similar presentations
All of Lab. 4 using Services Audio, LED, GPIO, LightSensor, Thermal Sensors, LCD Code by A. Tran / M. Smith Talk by M. Smith with slides from D. Lannigan.
Advertisements

EXTERNAL COMMUNICATIONS DESIGNING AN EXTERNAL 3 BYTE INTERFACE Mark Neil - Microprocessor Course 1 External Memory & I/O.
ECE 371 Unit 13 - Part 1 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.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
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.
Boot Issues Processor comparison TigerSHARC multi-processor system Blackfin single-core.
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.
Building a simple loop using Blackfin assembly code M. Smith, Electrical and Computer Engineering, University of Calgary, Canada.
Specialized Video (8-bit) and Vector (16-bit) Instructions on the Blackfin There is always a “MAKE-UP-YOUR-QUESTION-AND-ANSWER-IT” Question on a Dr. Smith.
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.
Core Timer Code Development How you could have done the Take- Home Quiz using a test driven development (TDD) approach.
HD44780 LCD programming From the Hardware Side Design and implementation details on the way to a valid SPI-LCD interface driver.
Specialized Video (8-bit) and Vector (16-bit) Instructions on the Blackfin Expand on these ideas for Q9 question and answer on the final.
Timers and Timing Signals Tutorial. 6/18/2015 Timer Control Copyright M. Smith, ECE, University of Calgary, Canada 2 / 31 Temperature Sensor -- Lab 3.
Understanding the Blackfin ADSP-BF5XX Assembly Code Format
Serial Peripheral Interface (SPI)
A look at interrupts What are interrupts and why are they needed.
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
Getting the O in I/O to work on a typical microcontroller Ideas of how to send output signals to the radio controlled car. The theory behind the LED controller.
Laboratory 1 – ENCM415 Familiarization with the Analog Devices’ VisualDSP++ Integrated Development Environment.
Getting the O in I/O to work on a typical microcontroller Activating a FLASH memory “output line” Part 1 Main part of Laboratory 1 Also needed for “voice.
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.
SPI Compatible Devices Design and implementation details on the way to a valid SPI-LCD interface driver.
Overview What kind of LCD Interfacing the LCD Displaying Text and Numbers Common Issues.
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
Developing a bicycle speed-o-meter Midterm Review.
Peripherals and their Control An overview of industrially available “peripheral devices” that use “pulse-width modulation” for information passing. Review.
EE 316 Computer Engineering Junior Lab Serial Ports, LCD Displays & PROMs.
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
PPI-8255.
CSCI1600: Embedded and Real Time Software Lecture 9: Input Output Concepts Steven Reiss, Fall 2015.
Department of Electronic & Electrical Engineering LCD character display (parallel interface). How to interface a LCD character display to a PIC.
Building a simple loop using Blackfin assembly code If you can handle the while-loop correctly in assembly code on any processor, then most of the other.
Lab3 -- Lab 4 Design and implementation details on the way to a valid SPI-LCD interface driver.
Lab3 -- Lab 4 Design and implementation details on the way to a valid SPI-LCD interface driver.
Developing a bicycle speed-o-meter
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.
Internet-of-Things (IoT)
SPI Compatible Devices
Thermal arm-wrestling
DMA example Video image manipulation
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
Building a simple loop using Blackfin assembly code
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.
Presentation transcript:

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

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 2 To be tackled today How do you send commands from the Blackfin to a LCD device? What commands are necessary to control the LCD device -- HD44780? How do we get the timing correct?

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 3 Functions we have now developed for Lab. 5 void Write_SPI_TDBR_ASM(ushort transmit_value); Write the value “transmit_value” to SPI TDBR register void ControlFLG5_ASM(ushort low_or_high) Activates FLS5 (select flag 5 bit) Sets FLG5 bit high or low as requested void WaitWhileSPIF_ASM(ushort low_or_high); Waits will SPI_STAT SPIF flag is low or high void Set_SPIregisters_ASM(ushort BAUD_SCALE) void Set_SIC_IMASK_ASM(ulong bit_to_set); void WriteSPI(ushort value)  All we will need today

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 4 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 SLAVE IGNORES INFORMATION UNLESS SLAVE SELECT LINE IS ACTIVE Information (bits) is clocked by SCLK signal. 1-bit, 1 clock tick MOSI --MASTER OUT – SLAVE IN

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 5 Now at the stage where we can do some experimenting with the hardware We know that the following pins are “key” to the operation of the interface. Place scope probes on these lines MOSI – this will show the data being transmitted from the SPI interface PF5 – chip select line When this is pulled low, then the slave will accept any data being transmitted, otherwise data is ignored When this goes – low to high – then the serial data transmitted to the slave is “latched” (converted into a parallel signal that is then sent to LCD as a data or a command request.

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 6 Known facts -- MOSI data is transmitted from Blackfin the moment that data is written to SPI_TDBR Blackfin Processor LCD SCREEN 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

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 7 Known facts -- MOSI data is accepted by the SLAVE if slave-select is active low – PF5 is low – Master/Slave Blackfin Processor LCD SCREEN 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

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 8 Known facts – The SLAVE only sends the data to the LCD when the PF5 line goes from low to high – interface design Blackfin Processor LCD SCREEN 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

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 9 Current Solutions and Problems Change to C++ programs as no longer taking directly to the hardware ClearScreen( ) { WriteSPI(0x0001); } WriteLetter(char letter) { WriteSPI(0x0200 | letter); Call CursorMoveASM} CursorMove ( ) { WriteSPI( 0x????); } etc How do we stop the LCD device from accepting too many commands? How do we know when the LCD device is ready for the next command?

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 10 ENABLE Signal

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 11 Enable signal Enable signal works on the high-to-low transition Send required signal to interface means Required signal + enable signal high Wait long enough for voltages to “settle” (stabilize) Required signal + enable signal low This strobes the information into the LCD screen Wait long enough for LCD command to work How long is “long enough”? Required signal + enable signal high Avoid “race” conditions to make sure that we don’t loose the signal

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 12 Hooking up the LCD WATCH OUT DB lines are ordered L-to-R LO to HIGH But data bit connector lines are labelled R-to-L

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 13 Blackfin transmits 16 bits with THIS format 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 )

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 14 LCD Instruction set

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 15 Current Solutions -- Instruction Change to C++ programs as no longer taking directly to the hardware #define ENABLE_BIT 0x100 #define R_W_BIT 0x200 #define DATA_BIT 0x400 ClearScreen( ) { #define ClearDisplayCommand 0x0001; WriteSPI(ClearDisplayCommand | ENABLE_BIT); Wait till voltages settle WriteSPI(ClearDisplayCommand); Wait for command to finish (1.64 ms – Lab 3 s, ms, us timer) WriteSPI(ClearDisplayCommand | ENABLE_BIT); }

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 16 Current Solutions -- Data Change to C++ programs as no longer taking directly to the hardware #define ENABLE_BIT 0x100 // Active low #define R_W_BIT 0x200 #define DATA_BIT 0x400 WriteLetter( char letter) { WriteSPI(letter | DATA_BIT | ENABLE_BIT); Wait till voltages settle WriteSPI(letter | DATA_BIT); Wait for command to finish (40 us – Lab 3 s, ms, us timer) WriteSPI(letter | DATA_BIT | ENABLE_BIT); }

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 17 Some commands LCD COMMANDS RSR/WDATA DB7 to DB0 ClearScreen( )000x01 CursorIncrease( )000x05 CursorMove( )000x10 DisplayOn( )000x0B WriteLetter(value)10value WriteLetter(‘a’)100x61 (ascii ‘a’) WriteLetter(‘A’)100x41 (ascii ‘A’)

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 18 SetUpDisplay( ) From the manual Send command 0x30 – wait 4 ms Send command 0x3C – wait 4 ms Don’t forget to send the command to “activate the screen” -- LCDDisplay(ushort On_or_OFF);

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 19 You write the code for LCDDisplay(ushort On_or_OFF); CursorMove(ushort left_or_right);

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 20 This was the solution of writing “Hello” to LCD SetUpDisplay( ); EnableDisplay( ); ClearDisplay( ); UseFixedTimeASM( ); CursorIncrease( ); UseFixedTimeASM( ); DisplayOn( ); Use FixedTimeASM( ); WriteLetter(‘H’); UseFixedTimeASM( ); CursorMove( ); UseFixedTimeASM( ); WriteLetter(‘e’); etc. General concept was there, Now fix the solution to write “Happy Christmas” to LCD screen Except for the wiring and demo Lab. 5 is essentially done Note: As of 24 th October the SPI interface was unstable for input to Blackfin DON’T connect input interface

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 21 Details of what is needed

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 22 Data to send a character Complicated or not? To cause “A” to appear on LCD screen need bit pattern = 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?

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 23 Now complete part of Lab. 4 LCD as video screen Now play the video game by moving the cursor on the LCD screen Minimum requirements Move the cursor in response to temperature changes Print “player 1” wins if cursor moves all the way to the right Print “player 2” wins if cursor moves all the way to the left

6/10/2015 SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 24 Information taken from Analog Devices On-line Manuals with permission 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.