Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > General Electronics Chat


General Electronics Chat This forum is for general chat about electronics, eg: Dont know what a part does? Dont know how to read a circuit? Want to get an opinion?

Reply
 
LinkBack Thread Tools Display Modes
Old 31st March 2008, 07:57 PM   (permalink)
Exclamation GLCD assembler code

Can someone provide me with a simple code for writing just one dot on a GLCD in assembler? The KS0108 control is used.
Electronics4you is offline  
Old 31st March 2008, 08:04 PM   (permalink)
Default

For which microcontroller?
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is online now  
Old 31st March 2008, 11:30 PM   (permalink)
Default

Sorry, it's for a PIC18F452
Electronics4you is offline  
Old 1st April 2008, 01:21 AM   (permalink)
Default

You can try and make some sense of this,
Code:
Plot		call	SetLCDAddress
		clrf	Mask
		movfw	YPos
		andlw	0x07
		movwf	Count
		bsf	STATUS,C
GetBit		rlf	Mask,F
		decf	Count,F
		btfss	Count,7
		goto	GetBit
		call	ReadData	;dummy read
		call	ReadData
		iorwf	Mask,F
		movfw	XPos
		andlw	0x3f
		iorlw	0x40
		call	WriteCMD
		movfw	Mask
		call	WriteData
		return

Cls_1		bsf	b_LCD_CS1
		bsf	b_LCD_CS2
		movlw	0x08
		movwf	ForI
ClsLoopI	movlw	0x40
		movwf	ForJ
		call	WriteCMD
		decf	ForI,W
		iorlw	0xb8
		call	WriteCMD
ClsLoopK	movlw	0x00		
		call	WriteData
		decfsz	ForJ,F
		goto	ClsLoopK
		decfsz	ForI,F
		goto	ClsLoopI
		clrf	XPos
		clrf	YPos
		return

InitLCD_1	bsf	b_LCD_CS1
		bsf	b_LCD_CS2
		movlw	0x3f
		call	WriteCMD
		movlw	0xc0
		call	WriteCMD
		movlw	0x40
		call	WriteCMD
		movlw	0xb8
		call	WriteCMD
		return

WaitNotBusy	bsf	STATUS,RP0
		movlw	0xff
		movwf	TRISB
		bcf	STATUS,RP0
		bsf	b_LCD_RW
		bcf	b_LCD_RS  
		btfss	b_LCD_CS1
		goto	Skip_CS1
		bcf	b_CS2
		btfsc	b_LCD_CS2
		bsf	b_CS2
		bcf	b_LCD_CS2
WNB1_Loop	bsf	b_LCD_E
		btfsc	PORTB,7
		goto	WNB1_Loop
		bcf	b_LCD_E
		btfsc	b_CS2
		bsf	b_LCD_CS2
Skip_CS1	btfss	b_LCD_CS2
		goto	Skip_CS2
		bcf	b_CS1
		btfsc	b_LCD_CS1
		bsf	b_CS1
		bcf	b_LCD_CS1
WNB2_Loop	bsf	b_LCD_E
		btfsc	PORTB,7
		goto	WNB2_Loop
		bcf	b_LCD_E
		btfsc	b_CS1
		bsf	b_LCD_CS1
Skip_CS2	bsf	STATUS,RP0
		clrf	TRISB
		bcf	STATUS,RP0
		return

ReadLCD		bsf	b_LCD_E
		movfw	PORTB
		bcf	b_LCD_E
		btfsc	b_Inverted
		xorlw	0xff
		return

WriteCMD	movwf	LCDTemp
		call	WaitNotBusy
		movfw	LCDTemp
		movwf	PORTB
		bcf	b_LCD_RW
		bcf	b_LCD_RS
		bsf	b_LCD_E
		bcf	b_LCD_E
		return

WriteData	movwf	LCDTemp
		call	WaitNotBusy
		movfw	LCDTemp
		btfsc	b_Inverted
		xorlw	0xff
		movwf	PORTB
		bcf	b_LCD_RW
		bsf	b_LCD_RS	;rs=1 rw=0
		bsf	b_LCD_E
		bcf	b_LCD_E
		return

ReadData	call	WaitNotBusy
		bsf	STATUS,RP0
		movlw	0xff
		movwf	TRISB
		bcf	STATUS,RP0
		bsf	b_LCD_RW
		bsf	b_LCD_RS
		bsf	b_LCD_E
		movfw	PORTB
		bcf	b_LCD_E
		btfsc	b_Inverted
		xorlw	0xff
		bsf	STATUS,RP0
		clrf	TRISB
		bcf	STATUS,RP0
		return

SetLCDAddress	bcf	b_LCD_CS1
		bcf	b_LCD_CS2
		btfss	XPos,6
		bsf	b_LCD_CS1
		btfsc	XPos,6
		bsf	b_LCD_CS2
		movfw	XPos
		andlw	0x3f
		iorlw	0x40
		call	WriteCMD
		movfw	YPos
		movwf	Row
		rrf	Row,F
		rrf	Row,F
		rrf	Row,F
		movfw	Row
		andlw	0x7
		iorlw	0xb8
		goto	WriteCMD
A few notes on the above code,
It's written for 16F886.
The TRIS registers need setting up.
It does everything inverted, cls fills the screen with ones and plot clears the bits.
The WaitNotBusy routine checks the CS bits to decide which side of the display to check. It may check both. It leaves the state of CS1/2 unchanged.
All variables starting b_ are bit variables - do,
Code:
#define		b_CS1		Flags,0
#define		b_CS2		Flags,1
#define		b_Inverted	Flags,2
#define		b_Font		Flags,3
#define		b_Fixed		Flags,4
#define		b_LineWidth	Flags,5

#define		b_LCD_CS1	PORTA,2
#define		b_LCD_CS2	PORTA,3
#define		b_LCD_RS	PORTC,5
#define		b_LCD_RW	PORTC,0
#define		b_LCD_E		PORTC,2
Sorry for the lack of comments.

Mike.
Pommie is online now  
Old 1st April 2008, 12:55 PM   (permalink)
Default

Just give me a couple of days,
Electronics4you is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
MP Lab Program Help bamafan54 Micro Controllers 3 19th October 2007 03:53 AM
chek code assembler gimmy Electronic Projects Design/Ideas/Reviews 10 4th May 2005 07:32 PM
Tough assembly program for the PIC16F84 asmpic Micro Controllers 34 3rd December 2004 07:50 PM
Prog to write assembler code in? Lac Micro Controllers 2 12th August 2004 11:09 PM
An error in pic16f84a, why? Zener_Diode Micro Controllers 6 11th April 2004 03:55 AM



All times are GMT. The time now is 04:01 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker