This is a multi-part message in MIME format. ------=_NextPart_000_7ee3_3273_7494 Content-Type: text/plain; format=flowed Hi Mark Here you go its for a 1x16 it prints the first sixteen letters of the alphabet Good Luck Ollie Wallock >From: Marc Nicholas >Reply-To: pic microcontroller discussion list >To: PICLIST@MITVMA.MIT.EDU >Subject: [EE]: 4-bit HD44780 code samples? >Date: Sun, 25 May 2003 11:11:16 -0400 > >Can anyone provide me with some code samples for HD44780 in 4-bit mode? >I've >got datasheets, FAQs, etc...just wanted to see some code :-) > >Thanks in advance. > > >-marc > >-------------------------------------------------- >Marc Nicholas Geekythings Inc. C/416.543.4896 >UNIX, Database, Security and Networking Consulting > >-- >http://www.piclist.com#nomail Going offline? Don't AutoReply us! >email listserv@mitvma.mit.edu with SET PICList DIGEST in the body _________________________________________________________________ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body ------=_NextPart_000_7ee3_3273_7494 Content-Type: text/plain; name="lcd4bit.asm"; format=flowed Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="lcd4bit.asm" ;*************************************** ;Written by Ollie Wallock ;for a course to be taught at STCC in The spring of 2000 ;saved as lcd4bit.asm ;for PIC 16F84 ;This is a take off on a program presented by David Benson "PIC'n up the PACE" ;Modifications to the initialization routine were strongly suggested by Myke Predko ;LCD OPTREX PWB 16117L DIGI KEY 73-1012-ND ;========================================================= ; 4 BIT MODE = ;========================================================= ;The first 16 lower case letters are displayed = ;========================================================= ;CONTROLLER HITACCI 44780 ;clock frequency 3.6864 Mhz ;************************************* ;PROGRAM FUNCTIONS______________________________________________ ;_______________________________________________________________ ; list p=16f84,f=inhx8m ; include "\progra~1\mplab\p16f84.inc" list p=16f84 radix hex INCLUDE "P16f84.inc" __CONFIG _CP_OFF &_WDT_OFF &_XT_OSC &_PWRTE_ON ; config 0xf9 ;; WDT Disabled, XT Oscillator ;=============================================================== ;Declarations counter equ 0x0c countOn equ 0x0d dbonCt equ 0x0e showCt equ 0x0f track equ 0x10 charCnt equ 0x11 lineCnt equ 0x12 char equ 0x13 temp equ 0x14 ;=============================================================== org 0x00 goto Start ;=============================================================== ;Subroutines init movlw 0x00 movwf PORTA ;turn off all outputs from goto initCont nop ;goto isr initCont movwf PORTB ;coming from ports bsf STATUS, RP0 ;bank switch movlw b'00011001' ;porta,1,2 output for for for clocking ;////////////////////////////////////////////////////////////// ; ; G + G A G A ; R 5 R 2 R 1 ; N V N N PORT B ; D D D 0 1 2 3 4 5 6 7 ; o o o o o o o o o o o o o o ; ---------------------------------------- ; | --------------------------------- | ; | | | | ; | | L C D | | ; | | | | ; | | | | ; | --------------------------------- | ; --------------------------------------- ; ;////////////////////////////////////////////////////////////// movwf TRISA & 07 movlw b'00000000' ;portb,0 -> 7 outputs 0 is input movwf TRISB & 07 ; movlw b'10000100' ;rb pullups off prescaler is 32 TMR0 Assigned to crystal ; movwf OPTION_REG & 07 bcf STATUS,RP0 movlw b'00000000' ;clear all bits movwf PORTB movwf PORTA movlw 0x0c movwf FSR retlw 0x00 ;====================================================================== Dly160 ; retlw 0x00 movlw 0x24 addlw 0xff btfss STATUS,Z goto $ - 0x02 retlw 0x00 ;====================================================================== Dly6d4ms ; retlw 0x00 movlw 0x28 movwf counter call Dly160 decfsz counter,f goto $ - 0x02 retlw 0x00 ;====================================================================== ;====================================================================== SendByte movwf temp movf temp,w call NybbleOut swapf temp,w call NybbleOut call Dly160 retlw 0x00 ;====================================================================== NybbleOut movwf PORTB bsf PORTA,1 nop bcf PORTA,1 retlw 0x00 ;====================================================================== InitLcd; bcf PORTA,1 ;E line low bcf PORTA,2 ;R/S line low set to receive an instruction ; call Dly160 movlw 0x38 ;8 bit mode call NybbleOut call Dly6d4ms movlw 0x38 ;8 bit mode call NybbleOut call Dly160 movlw 0x38 ;8 bit mode call NybbleOut call Dly160 movlw 0x28 ;4 biit mode call NybbleOut call Dly160 movlw 0x28 ;4 bit mode 5x7 mode call SendByte movlw 0x0f ;display on cursor blink at left call SendByte movlw 0x01 ;clear display = blanks call SendByte movlw 0x06 ;increment mode no shift call SendByte retlw 0x00 ;====================================================================== Disp16 bcf PORTA,1 ;E line lo bcf PORTA,2 ;R/S line low prepare for instruction ; call Dly160 movlw 0x80 ;control word = address of start of the first byte call SendByte bcf PORTA,1 ;E line lo bsf PORTA,2 ;R/S line high to display data call Dly6d4ms movlw 'a' movwf char movlw 0x02 movwf lineCnt Show8Chars movlw 0x08 movwf charCnt ShowChar movfw char call SendByte decfsz charCnt,f goto NextChar goto Next8Chars_ NextChar incf char,f goto ShowChar Next8Chars_ decfsz lineCnt,f goto Next8Chars goto EndDisp16 Next8Chars bcf PORTA,1 ;E line lo bcf PORTA,2 ;R/S line low for command ; call Dly160 movlw 0xc0 ;address of the start of the second byte call SendByte bcf PORTA,1 ;E line lo bsf PORTA,2 ;R/S line high to display data ; call Dly160 incf char,f goto Show8Chars EndDisp16 retlw 0x00 ;====================================================================== ;====================================================================== Start call init main call Dly6d4ms call Dly6d4ms call Dly6d4ms call InitLcd call Disp16 goto $ ;???????????????????????????????????????????????????? end -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body ------=_NextPart_000_7ee3_3273_7494--