Return-Path: robot-board@oberon.com Received: by media.mit.edu (5.57/DA1.0.4.amt) id AA07422; Mon, 4 Apr 94 16:29:06 -0400 Received: from ([127.0.0.1]) by oberon.com (4.1/SMI-4.1_Armado.MX) id AA12154; Mon, 4 Apr 94 16:22:41 EDT Date: Mon, 4 Apr 94 16:22:41 EDT Message-Id: <9404042020.AA07296@gopher.cray.com> Errors-To: gkulosa@oberon.com Reply-To: kilian@pecan.cray.com Originator: robot-board@oberon.com Sender: gkulosa@oberon.com Precedence: bulk From: kilian@pecan.cray.com (Alan Kilian) To: Multiple recipients of list Subject: Re: LCD routines X-Listprocessor-Version: 6.0b -- ListProcessor by Anastasios Kotsikonas Here are some routines I wrote for those "Character" lcd display modules They all seem to have a standard 14-pin TTL interface. Look at the 6270 documentation, or contact me for more info. -Alan Kilian * * Author: Alan Kilian kilian(at)cray.com * * Title : HC11 LCD driver routines * * File Name : lcd.asm * * Description : This program demonstrates the use of a HC11 processor * to control a LCD panel * * History : 02/10/93 Created. * 02/11/93 Added power-up delay * * Port usage: * PORTC Bit0 = DB0 through BIT7 = DB7 * PORTA Bit7 = E Bit6 = RS Bit5 = RW * * Note : This program is written for the MC68HC811E2 processor running * in single-chip mode. It is designed for use with a processor * running with an 8 mHz crystal. If you are using a different * crystal frequency you will need to re-compute all of the * timing values in this code. * * The structure, serial I/O and command processor portions of * this program evolved from the program HEXLOB40 written by * Fred Martin and Randy Sargent and we thank them greatly. **************************************************************************** * One-Byte Registers PORTA EQU $1000 PACTL EQU $1026 PORTB EQU $1004 ; PORT B data register PORTC EQU $1003 DDRC EQU $1007 TCTL1 EQU $1020 ; Timer ConTroL register 1 TCTL2 EQU $1021 ; Timer ConTroL register 2 TMSK1 EQU $1022 ; Timer interrupt MaSK register 1 TFLG1 EQU $1023 ; Timer interrupt FLaG register 1 RTFLG1 EQU $23 ; Relative to $1000 Timer interrupt FLaG register 1 TMSK2 EQU $1024 ; Timer interrupt MaSK register 2 TFLG2 EQU $1025 ; Timer interrupt FLaG register 2 SPCR EQU $1028 ; SPI Control Register BAUD EQU $102B ; SCI Baud Rate Control Register SCCR2 EQU $102D ; SCI Control Register 2 SCSR EQU $102E ; SCI Status Register (Actual location) SCDR EQU $102F ; SCI Data Register (Actual location) * Masks for the PORTA LCD control signals LCD_E EQU $80 ; Bit 7 of PORTA LCD_RS EQU $40 ; Bit 6 of PORTA LCD_RW EQU $20 ; Bit 5 of PORTA * Masks for PORTC direction ALL_OUTPUT EQU $FF ; 1 = output, 0 = input ALL_INPUT EQU $00 ; Store in DDRC * The BUSY bit on PORTC BUSY EQU $80 ; Bit 7 of PORTC * The names of the LCD registers MODE EQU $00 PITCH EQU $01 NCHARS EQU $02 DUTY EQU $03 CURPOS EQU $04 DUMMY1 EQU $05 ; There is no command 5 DUMMY2 EQU $06 ; There is no command 6 DUMMY3 EQU $07 ; There is no command 7 DSLOW EQU $08 DSHIGH EQU $09 CURLOW EQU $0A CURHIGH EQU $0B WRDAT EQU $0C RDDAT EQU $0D CLRBIT EQU $0E SETBIT EQU $0F * Values for various LCD things DISPLAY_WIDTH EQU 256 ; Pixels wide DISPLAY_HEIGHT EQU 64 ; Pixels tall DUTY_CYCLE EQU 32 ; 1/32 DECIMAL duty cycle CHAR_WIDTH EQU 8 ; How wide is the char cell? CHAR_HEIGHT EQU 8 ; How tall is the char cell? CURSOR_LINE EQU 8 ; Cursor is on line 8 of the char cell * Bits for the mode command DISPLAY_ON EQU $20 ; Is the display on? MASTER EQU $10 ; Master/Slave mode BLINK EQU $08 ; Does the cursor blink? CURSOR_ON EQU $04 ; Is the cursor displayed? GRAPHICS_MODE EQU $02 ; Graphics or character mode? EXTERNAL_CG EQU $01 ; Is the character generator internal? ******************************************************************************** * zero page RAM definitions. Do not use FCB here. It will stomp EEBOOT20. ******************************************************************************** ORG $00 ; The beginning of RAM BUSY_FLAG RMB 1 ********************************************************************** * MAIN CODE * ********************************************************************** ORG $F800 ; $F800 is the beginning of EEPROM * ; on a MC68HC811E2 processor Start: LDS #$00FF ; Set stack at the top of ram LDAA #$FF ; Delay to allow the LCD panel to power-up lp: LDAB #$FF lp1: DECB NOP NOP NOP NOP NOP NOP BNE lp1 DECA BNE lp JSR LCD_SET ; Setup the ports properly JSR home ; Set the display to the home position mainloop: JSR PRTSTR BRA mainloop home: LDAA #DSLOW ; Set display address low JSR SELECT_REG LDAA #$00 ; Start displaying at address zero JSR STORE_REG LDAA #DSHIGH ; Set display address high JSR SELECT_REG LDAA #$00 ; Start displaying at address zero JSR STORE_REG LDAA #CURLOW ; Set cursor address low JSR SELECT_REG LDAA #$00 ; Put the cursor at address zero JSR STORE_REG LDAA #CURHIGH ; Set cursor address high JSR SELECT_REG LDAA #$00 ; Put the cursor at address zero JSR STORE_REG RTS PRTSTR: LDX #STR PRT0 LDAA #WRDAT JSR SELECT_REG LDAA 0,X CMPA #'=' ;String terminates with a '=' character BEQ PRT1 JSR STORE_REG INX BRA PRT0 PRT1: RTS LCD_SET LDAA #ALL_OUTPUT STAA DDRC LDAA #%10001000 STAA PACTL LDAA #MODE ; Command 0 Mode control JSR SELECT_REG LDAA #DISPLAY_ON|MASTER|BLINK|CURSOR_ON JSR STORE_REG LDAA #PITCH ; Command 1 Character pitch JSR SELECT_REG LDAA #CHAR_HEIGHT-1 ; Get the height ASLA #4 ; into the upper 4 bits ORAA #CHAR_WIDTH-1 ; width in the lower 4 bits JSR STORE_REG ; Fits the 7 X 5 font LDAA #NCHARS ; Command 2 Number of characters JSR SELECT_REG LDAA #(DISPLAY_WIDTH/CHAR_WIDTH)-1 JSR STORE_REG LDAA #DUTY ; Command 3 Duty cycle JSR SELECT_REG LDAA #DUTY_CYCLE-1 JSR STORE_REG LDAA #CURPOS ; Command 4 Cursor position JSR SELECT_REG LDAA #CURSOR_LINE-1 JSR STORE_REG RTS SELECT_REG PSHA LDAA #ALL_OUTPUT STAA DDRC PULA STAA PORTC ; Set the data lines LDAA #LCD_RS ; Set RS high. STAA PORTA ; This selects the instruction register LDAA #LCD_RS|LCD_E ; Set RS and E high STAA PORTA LDAA #LCD_RS ; Set E low STAA PORTA LDAA #$00 ; Set RS low also. STAA PORTA JSR WAIT_BUSY RTS STORE_REG LDAA #ALL_OUTPUT STAA DDRC STAA PORTC ; Set the data lines LDAA #LCD_E ; Set E High STAA PORTA LDAA #$00 ; Set E low again STAA PORTA JSR WAIT_BUSY RTS WAIT_BUSY: LDAA #ALL_INPUT STAA DDRC LDAA #LCD_RS|LCD_RW ; Make sure to meet setup/hold times STAA PORTA LDAA #LCD_RS|LCD_RW|LCD_E STAA PORTA waitloop: LDAA PORTC ANDA #BUSY BNE waitloop ; Wait until the BUSY bit goes zero LDAA #LCD_RS|LCD_RW STAA PORTA LDAA #$00 ; Make sure to meet setup/hold times STAA PORTA RTS STR FCC 'Shutter Speed = ' BadInt RTI ; Set all unused vectors here Org $FFC0 ; Where the interrupt vectors are FDB BadInt * $FFC0 ; Reserved FDB BadInt * $FFC2 ; Reserved FDB BadInt * $FFC4 ; Reserved FDB BadInt * $FFC6 ; Reserved FDB BadInt * $FFC8 ; Reserved FDB BadInt * $FFCA ; Reserved FDB BadInt * $FFCC ; Reserved FDB BadInt * $FFCE ; Reserved FDB BadInt * $FFD0 ; Reserved FDB BadInt * $FFD2 ; Reserved FDB BadInt * $FFD4 ; Reserved FDB BadInt * $FFD6 ; SCI Serial System FDB BadInt * $FFD8 ; SPI Serial Transfer Complete FDB BadInt * $FFDA ; Pulse Accumulator Input Edge FDB BadInt * $FFDC ; Pulse Accumulator Overflow FDB BadInt * $FFDE ; Timer Overflow FDB BadInt * $FFE0 ; In Capture 4/Output Compare 5 (TI4O5) FDB BadInt * $FFE2 ; Timer Output Compare 4 (TOC4) FDB BadInt * $FFE4 ; Timer Output Compare 3 (TOC3) FDB BadInt * $FFE6 ; Timer Output Compare 2 (TOC2) FDB BadInt * $FFE8 ; Timer Output Compare 1 (TOC1) FDB BadInt * $FFEA ; Timer Input Capture 3 (TIC3) FDB BadInt * $FFEC ; Timer Input Capture 2 (TIC2) FDB BadInt * $FFEE ; Timer Input Capture 1 (TIC1) FDB BadInt * $FFF0 ; Real Time Interrupt (RTI) FDB BadInt * $FFF2 ; External Pin or Parallel I/O (IRQ) FDB BadInt * $FFF4 ; Pseudo Non-Maskable Interrupt (XIRQ) FDB BadInt * $FFF6 ; Software Interrupt (SWI) FDB BadInt * $FFF8 ; Illegal Opcode Trap () FDB BadInt * $FFFA ; COP Failure (Reset) () FDB BadInt * $FFFC ; COP Clock Monitor Fail (Reset) () FDB Start * $FFFE ; /RESET END