More (up a level)... Connecting the Nokia 3510i LCD to a Microchip PIC16F84 microcontroller

Similar documents
Embedded Systems. PIC16F84A Sample Programs. Eng. Anis Nazer First Semester

16.317: Microprocessor Systems Design I Fall 2013 Exam 3 Solution

Assembly Language Instructions

16.317: Microprocessor-Based Systems I Spring 2012

16.317: Microprocessor-Based Systems I Summer 2012

PIC 16F84A programming (II)

Lecture (04) PIC16F84A (3)

Chapter 4 Sections 1 4, 10 Dr. Iyad Jafar

Chapter 13. PIC Family Microcontroller

SOLUTIONS!! DO NOT DISTRIBUTE!!

/ 40 Q3: Writing PIC / 40 assembly language TOTAL SCORE / 100 EXTRA CREDIT / 10

TOPIC 3 INTRODUCTION TO PIC ASSEMBLY LANGUAGE. E4160 Microprocessor & Microcontroller System. Prepared by : Puziah Yahaya JKE, POLISAS / DEC 2010

Instuction set

Dept. of Computer Engineering Final Exam, First Semester: 2016/2017

CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT. Spring 2006

Chapter 5 Sections 1 6 Dr. Iyad Jafar

Lesson 14. Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27)

ECE Test #1: Name

Application Note - PIC Source Code v1.1.doc

APPLICATION NOTE 2361 Interfacing an SPI-Interface RTC with a PIC Microcontroller

LAB WORK 2. 1) Debugger-Select Tool-MPLAB SIM View-Program Memory Trace the program by F7 button. Lab Work

Flow Charts and Assembler Programs

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE6008 Microcontroller based system design

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 RESIT. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J1. Time allowed: 3 Hours

ECE Homework #3

PIC16F87X 13.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002. Semester 2. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J2. Time allowed: 3 Hours

DERTS Design Requirements (1): Microcontroller Architecture & Programming

A Better Mouse Trap. Consumer Appliance, Widget, Gadget APPLICATION OPERATION: Ontario, Canada

EEE111A/B Microprocessors

16.317: Microprocessor-Based Systems I Fall 2012

D:\PICstuff\PartCounter\PartCounter.asm

EECE.3170: Microprocessor Systems Design I Summer 2017 Homework 5 Solution

Micro II and Embedded Systems

Q1: Multiple choice / 20 Q2: Protected mode memory accesses. / 40 Q3: Reading PIC. / 40 assembly language TOTAL SCORE / 100

THE UNIVERSITY OF THE WEST INDIES

SOLUTIONS!! DO NOT DISTRIBUTE PRIOR TO EXAM!!

AN587. Interfacing to an LCD Module. Interfacing to an LCD Module INTRODUCTION OPERATION CONTROL SIGNAL FUNCTIONS TABLE 2: CONDITIONAL ASSEMBLY FLAGS

Section 31. Instruction Set

APPLICATION NOTE Wire Communication with a Microchip PICmicro Microcontroller

Discrete Logic Replacement Message Dispatch Engine

Chapter 5. Problems All programming problems should include design pseudo code either as a separate design document on embedded comments in the code.

Embedded System Design

Controller Provides Display of Monitored Process Deviation

Hi Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

S w e d i s h c r. w e e b l y. c o m j a l i l a h m e l i v e. c o m Page 1

University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory

movwf prevcod ; a new button is pressed - rcnt=3 movwf (mtx_buffer+1) movlw 3 movwf rcnt

Fortune. Semiconductor Corporation 富晶半導體股份有限公司. 8-bit MCU with 1k program ROM, 64-byte RAM, 1 R2F module and 3 13 LCD driver. TD Rev. 1.

PIC Discussion. By Eng. Tamar Jomaa

Outline. Micriprocessor vs Microcontroller Introduction to PIC MCU PIC16F877 Hardware:

Graphical LCD Display Datasheet EB

Week1. EEE305 Microcontroller Key Points

Outlines. PIC Programming in C and Assembly. Krerk Piromsopa, Ph.D. Department of Computer Engineering Chulalongkorn University

ECE 354 Introduction to Lab 2. February 23 rd, 2003

Arithmetic,logic Instruction and Programs

PIC16F84A 7.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS

Introduction to PIC Programming

ECE 354 Computer Systems Lab II. Interrupts, Strings, and Busses

EXPERIMENT 4: Parallel Input/Output. Objectives Introduction to the Parallel Input/Output (I/O) Familiarization to Interfacing

The University of Texas at Arlington Lecture 7

ALU and Arithmetic Operations

When JP1 is cut, baud rate is Otherwise, baud rate is Factory default is that JP1 is shorted. (JP1 is jumper type in some model)

16.317: Microprocessor Systems Design I Fall Exam 3 December 15, Name: ID #:

Binary Outputs and Timing

DATA SHEET. article numbers P125-1b & P125-1g

SOLAR TRACKING SYSTEM USING PIC16F84A STEPPER MOTOR AND 555TIMER

ECE 354 Computer Systems Lab II. Memory and Indirect Addressing

Hardware Interfacing. EE25M Introduction to microprocessors. Part V. 15 Interfacing methods. original author: Feisal Mohammed

PART TWO LISTING 8 PROGRAM TK3TUT8 MOVF PORTA,W ANDLW B ADDWF COUNT,F MOVF COUNT,W MOVWF PORTB GOTO LOOP

16.317: Microprocessor Systems Design I Fall 2015

Input/Output Ports and Interfacing

PIC PROGRAMMING START. The next stage is always the setting up of the PORTS, the symbol used to indicate this and all Processes is a Rectangle.

16.317: Microprocessor Systems Design I Spring 2015

Interfacing PIC Microcontrollers. ADC8BIT2 Schematic. This application demonstrates analogue input sampling

EECE.3170: Microprocessor Systems Design I Spring 2016

Chapter 10 Sections 1,2,9,10 Dr. Iyad Jafar

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE Microcontroller Based System Design

CONNECT TO THE PIC. A Simple Development Board

Designed to GO... Universal Battery Monitor Using the bq2018 Power Minder IC. Typical Applications. Features. Figure 1. bq2018 Circuit Connection

Section 4. Architecture

Embedded Systems Design (630470) Lecture 4. Memory Organization. Prof. Kasim M. Al-Aubidy Computer Eng. Dept.

/ 28 HLL assembly Q4: Conditional instructions / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10

Keywords: CRC, CRC-7, cyclic redundancy check, industrial output, PLC, programmable logic controller, C code, CRC generation, microprocessor, switch

PTK8756B 8 Bit Micro-controller Data Sheet

/* PROGRAM FOR BLINKING LEDs CONEECTED TO PORT-D */

Wireless Model Rocket Igniter, William Grill, Riverhead Systems

ME 6405 Introduction to Mechatronics

Timer2 Interrupts. NDSU Timer2 Interrupts September 20, Background:

4.5.1) The Label Field ) The Mnemonic Field. 4.5) Assembly Language Program Structure A PIC18 ALP consists of 3 type of statements:

Done 1 NVB THF TLF T/R POL 1SHOT. Figure 1: Status register

LPTCOM. Bruce Misner Lakehead University h d3 RD2 pin 21. RD3 pin h d4. RD4 pin 27 RD5 pin h d5. RD6 pin 29 RD7 pin H d6

RISC8 Core Page 1. RISC8 Core. Version 1.0. Written by Tom Coonan

16.317: Microprocessor Systems Design I Fall 2014

TM57PA20/ TM57PA40. 8 Bit Microcontroller. User Manual. Tenx reserves the right to change or discontinue this product without notice.

PIC16C63A/65B/73B/74B

Chapter 11: Interrupt On Change

Performance & Applications

The University of Texas at Arlington Lecture 5

DISCONTINUED. SPI Communication with AMT bit Absolute Encoder

Transcription:

1 von 8 24.02.2010 21:53 More (up a level)... Connecting the Nokia 3510i LCD to a Microchip PIC16F84 microcontroller As with the FPGA board previously, the connections are made by soldering standard IDC ribbon cable directly to the glass substrate. As the PIC will not work from 3.3V, I had to make a power supply for the LCD. For this I used an LM317, is complete overkill but easy and quick. Both LCD supply pins are tied to the output, which is around 3.0V. All four signal lines have 10K resistors in series, to protect the LCD inputs from the 5V signalling of the PIC. This time the LCD decoupling is taken care of by a 1nF ceramic cap in parallel with a 4.7uF electrolytic, positive side to pad 8 of the LCD, negative to ground. This results in a rock steady image. My lash-up for testing the PIC. Note the resistors in the signal paths. Crystal frequency is 3.6864MHz, well within the 16F84's maximum of 4MHz. PIC is continuously writing this rolling, XOR pattern to the display. (Pixel brightness

2 von 8 24.02.2010 21:53 = X co-ord XOR Y co-ord). Refresh rate is a little disappointing at only 2Hz! Next version will be with either a faster PIC, or a PIC with a hardware serial port, or both. Here's the assembly code for PIC16F84 and MPASM. You can save this as a separate file from your own program, just make sure you put both this file and your own in the project. You will need to delcare any of the routines defined here you want to at the top of your code as "extern". See the MPASM documentation on how to do this. It's pretty simple! All the routines I've exported are declared "global" (see declarations near the top of the listing). The LCD starts up in 12 bit color mode (12BPP), and I've only made it work successfully in this mode. If you're only going to display text, then 8BPP mode will be adequate and probably much faster. When using 12BPP mode, "LCD3510_WritePixelPair" to write two pixels at a time. You pass a pointer to your 6-byte RAM array in the W-register. This procedure uses only the most significant four bits of each byte. Nokia 3510i colour LCD interface routines MPASM assembler, PIC16F84 neil_manc@yahoo.com 11/10/2005 11/10 NS Created list p = 16f84 #include p16f84.inc ports and pins for display interface #define NRESET PORTB, 0 #define NCS PORTB, 1 #define SCK PORTB, 3 #define SDA PORTB, 2 declarations for exported functions global LCD3510_Initialise global LCD3510_BeginWritePixel global LCD3510_WritePixel global LCD3510_WritePixelPair global LCD3510_CASET global LCD3510_PASET global LCD3510_SET_12BPP global LCD3510_SET_8BPP global LCD3510_Command global LCD3510_Parameter local storage lcd_if_data _ctr_i res 1 _ctr_j res 1 _ctr_n res 1 _ctr_w1 res 1 _ctr_w2 res 1 _s_byte res 1 _c_byte res 1 udata relocatable code starts here lcd_interface code look-up table for display initialisation sequence. with index

3 von 8 24.02.2010 21:53 in W reg. each element consists of <parameter count> <command code> [<parameter> [<parameter [<parameter>... ]]] _init_seq addwf PCL, f retlw 0xC6 retlw 0xB9 retlw.7 retlw 0xB6 28 28 29 retlw.84 retlw.69 retlw.82 retlw.67 initial escape refresh set display control 5 retlw 0xB3 setup greyscale map 0 retlw 0x11 retlw 0x22 retlw 0x33 retlw 0x44 retlw 0x55 retlw 0x66 retlw 0x77 retlw 0x88 retlw 0x99 retlw 0xAA retlw 0xBB retlw 0xCC retlw 0xDD retlw 0xEE retlw 0xFF retlw 0xB5 retlw 0xBD retlw 0xBE retlw.4 retlw 0x11 retlw.2 retlw 0xBA 27 retlw.3 retlw 0x25 retlw.70 retlw.20 retlw 0x2D retlw 0x00 retlw 0x02 gamma curve set common driver output power supply setup sleep out voltage control contrast colour look up table for 8BPP mode red (8 levels)

4 von 8 24.02.2010 21:53 retlw 0x04 retlw 0x06 retlw 0x09 retlw 0x0B retlw 0x0D retlw 0x0F retlw 0x00 retlw 0x02 retlw 0x04 retlw 0x06 retlw 0x09 retlw 0x0B retlw 0x0D retlw 0x0F retlw 0x00 retlw 0x05 retlw 0x0A retlw 0x0F green (8 levels) blue (4 levels) 3 retlw 0xB7 setup temp gradient -.05(n+1)%/K, 0 <= (n) < 4 all zeros(?) from here on: used during factory testing retlw 0x03 retlw 0xED retlw 0x21 retlw 0x29 booster voltage on end of sequence! inversion on display on short wait (for debugging) _short_wait clrf _ctr_w2 incf _ctr_w2 clrf _ctr_w1 goto wait_loop waits 50ms (at 4MHz) TODO: find a way of automating this _wait_5ms movlw 70 movwf _ctr_w2 clrf _ctr_w1 wait_loop decfsz _ctr_w1, F goto wait_loop decfsz _ctr_w2, F goto wait_loop exported function: LC3510_Command used for sending misc command bytes to the display

5 von 8 24.02.2010 21:53 LCD3510_Command sends a command byte to the display. with command stored in W register _command movwf _s_byte save W reg bsf NCS terminate any prior sequence of parameters per_cycle_wait NCS per_cycle_wait first bit is zero for command data pin high, ready for byte sending goto send_byte exported function: LC3510_WritePixel pixel value stored in W register writes one 8BPP pixel to display LCD3510_WritePixel exported function: LC3510_Parameter used for sending misc parameter bytes to the display LCD3510_Parameter sends a parameter byte to the display. with parameter in W register movwf _s_byte save W reg clock in a one for parameter send_byte btfss _s_byte, 7 unrolled byte serialisation loop btfsc _s_byte, 6 btfss _s_byte, 6 btfsc _s_byte, 5 btfss _s_byte, 5 btfsc _s_byte, 4 btfss _s_byte, 4

6 von 8 24.02.2010 21:53 btfsc _s_byte, 3 btfss _s_byte, 3 btfsc _s_byte, 2 btfss _s_byte, 2 btfsc _s_byte, 1 btfss _s_byte, 1 btfsc _s_byte, 0 btfss _s_byte, 0 exported function: LCD3510_initialise no paramters LCD3510_Initialise STATUS, RP1 bsf STATUS, RP0 bsf bsf bsf NRESET set ports to be outputs NCS SDA SCK STATUS, RP0 NRESET NCS SDA SCK _wait_5ms bsf NRESET movlw 0x01 send soft reset bsf NCS _wait_5ms clrf _ctr_i begin display initialisation loop disp_init_loop movf _ctr_i, W get number of parameters _init_seq movwf _ctr_n incf _ctr_i, F xorlw 0xED btfsc STATUS, Z goto init_end test for end of sequence movf _ctr_i, W send command byte

7 von 8 24.02.2010 21:53 incf _ctr_i, F _init_seq _command movf _ctr_n, F test if n = 0 (no parameters) btfsc STATUS, Z goto disp_init_loop init_param_loop get each parameter and send to display movf _ctr_i, W incf _ctr_i, F _init_seq decfsz _ctr_n, F goto init_param_loop goto disp_init_loop init_end _wait_5ms time for booster voltage to settle movlw 0x21 inversion on movlw 0x29 display on bsf NCS terminate final parameter sequence exported function: LCD3510_BeginWritePixel no parameters LCD3510_BeginWritePixel movlw 0x2C write memory command exported function: LC3510_WritePixelPair pointer to six-byte array of RGB values stored in W register writes two adjacent 12BPP pixels to display LCD3510_WritePixelPair movwf FSR movf INDF, W andlw 0xF0 movwf _c_byte swapf INDF, W andlw 0x0F iorwf _c_byte, W movf INDF, W andlw 0xF0 movwf _c_byte swapf INDF, W andlw 0x0F iorwf _c_byte, W movf INDF, W andlw 0xF0 movwf _c_byte

8 von 8 24.02.2010 21:53 swapf INDF, W andlw 0x0F iorwf _c_byte, W exported function: LC3510_CASET pointer to two-byte array stored in W register: start column no. and end column respectively. LCD3510_CASET movwf FSR movlw 0x2A movf incf movf INDF, W FSR, F INDF, W exported function: LC3510_PASET pointer to two-byte array stored in W register: start row no. and end row respectively. LCD3510_PASET movwf FSR movlw 0x2B movf incf movf INDF, W FSR, F INDF, W exported function: LC3510_SET_12BPP: pixels are packed RRRRGGGGBBBB no parameters LCD3510_SET_12BPP movlw 0x3A movlw 0x03 exported function: LC3510_SET_8BPP. pixels are packed RRRGGGBB no parameters LCD3510_SET_8BPP movlw 0x3A movlw 0x02 end up one level