Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 3rd October 2007, 07:57 AM   (permalink)
Default pic and graphic lcd

hi guys

i am having some problems getting a graphics lcd display k0108 to interface with a pic 16f887

maye someone can help me here

i am using asembler language as this i am an old timer and dont understand c as well as i dont have any compilers for c so asembly language it is.

here are my problems
1) i seem to be able to reset the display and switch it on when i do this part of the routine i get all the pixels on this is not to much of a problem as i can send a couple of commands to clear the screen so i can turn on the pixels that i want. but according to all the datasheets i have been able to get hld of on the internet if you do a reset then the display should return to position 0. i would think that it should aslo clear the screen.

this is not happening what appears to be happening is that the glcd has some type of memory in it so when a reset is done it goes back to the place it already is at and does not clear the display.

2) also there seems to be a problem with the adresses as if i point to position 1 page 0 z=0 then the display goes to seven pixels across, so if i put in a y adress of 58 then it starts at the beginging of the line.

3) also if i try to write to cs1 and cs2 together then the lcd does not respond
to any changes after the first write i gather therefore you have to access the one then the other.


please could someone look at my code and then let me know where i am going wrong if at all
Attached Files
File Type: asm GLCDTEST.asm (9.2 KB, 35 views)
IZACH is offline  
Old 3rd October 2007, 08:29 AM   (permalink)
Default

You appear to be doing something strange with the Enable line. The Enable line should be low all the time and pulsed high to read/write to the display.

These are specific to my hardware but should give you some idea.
Code:
InitLCD		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	call	SetInput
		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
SetOutput	bsf	STATUS,RP0
		clrf	TRISB
		bcf	STATUS,RP0
		return

SetInput	bsf	STATUS,RP0
		movlw	0xff
		movwf	TRISB
		bcf	STATUS,RP0
		return

ReadLCD		bsf	b_LCD_E
		movfw	PORTB
		bcf	b_LCD_E
		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
		movwf	PORTB
		bcf	b_LCD_RW
		bsf	b_LCD_RS	;rs=1 rw=0
		bsf	b_LCD_E
		bcf	b_LCD_E
		return

Cls		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
The WaitNotBusy routine is a little convoluted as I test both displays dependant on if the CS lines are high. Sorry about the lack of comments.

HTH

Mike.
Pommie is offline  
Old 3rd October 2007, 08:51 AM   (permalink)
Default

On the GLCD I owned, there is no RESET command one can send to the GLCD. When powered up, the GLCD enters a RESET state and user can check if the reset operation has finished via reading the STATUS byte and testing a bit in it.

The reset operation will not clear what was displayed on the LCD. In fact, on mine the previous data still remains even if I remove the main power for a few seconds and power it up again. Therefore user must be pro-active to clear the display by writing to every pixel to switch it off. This can be easily done via a loop.

With regard to the pixel addressing, you need to check the datasheet. I offer an image to help you along in understanding the addressing scheme.

You simply cannot write to both GLCD Controllers at the same time, similar to one cannot write to two memory locations at once.
Attached Images
File Type: gif GLCD.gif (29.3 KB, 28 views)
__________________
L.Chung
eblc1388 is offline  
Old 3rd October 2007, 08:58 AM   (permalink)
Default

I just looked at the data sheet and reset only sets Z=0 not X & Y and doesn't clear the display.
One other thing, in the above data sheet it does not mention the fact that to read data from the display, you have to do a dummy read first.

Mike.
Pommie is offline  
Old 3rd October 2007, 09:01 AM   (permalink)
Default

Quote:
Originally Posted by eblc1388
You simply cannot write to both GLCD Controllers at the same time, similar to one cannot write to two memory locations at once.
Oh yes you can. My clear screen routine above does exactly that.

You cannot read from both at the same time, hence my convoluted TestNotBusy routine.

Mike.
Pommie is offline  
Old 3rd October 2007, 09:04 AM   (permalink)
Default

Thanks Guys I Am Going To Give These A Try And Will Get Back To You
IZACH is offline  
Old 3rd October 2007, 09:12 AM   (permalink)
Default

Quote:
Originally Posted by Pommie
Oh yes you can. My clear screen routine above does exactly that.

You cannot read from both at the same time, hence my convoluted TestNotBusy routine.

Mike.
Thanks Mike. That's very useful to know. Can save half the time in clearing the display.
__________________
L.Chung
eblc1388 is offline  
Old 9th October 2007, 06:13 AM   (permalink)
Default pic to glc

thanks pommie

seems that i was reading the datasheet incorrectly as after you gave me that code and i repaired mine it works.

thanks if you would like to see the finished code i will post it it might be interesting for someone else????

thanks
IZACH is offline  
Old 27th October 2007, 09:46 AM   (permalink)
Default

If anyone is interested I use two 'LS164's to interface to my KS0108 display so I can drive it with two I/O pins only. You can't read the diaplay status but sometimes that is not as important as saving pins I/O so you can use the display with say, a 12F675.
Gordz is offline  
Old 27th October 2007, 02:21 PM   (permalink)
Default

So, you add two extra chips rather than use a bigger pic chip.

Mike.
Pommie is offline  
Old 27th October 2007, 02:40 PM   (permalink)
Default

Quote:
Originally Posted by Pommie
So, you add two extra chips rather than use a bigger pic chip.

Mike.
It appears to be some kind of PIC users disease. I dislike glue logic unless I have a good reason for it.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is online now  
Old 27th October 2007, 02:43 PM   (permalink)
Default

Quote:
Originally Posted by blueroomelectronics
It appears to be some kind of PIC users disease. I dislike glue logic unless I have a good reason for it.
Basically it's 30 year old thinking - adding extra chips to make a micro-processor useable. The whole point of a micro-controller is that it's mainly a single chip solution - although there are obvious occasions when 'glue' chips may be useful, but starting off with a chip you know is far too small isn't really one of them.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 27th October 2007, 04:11 PM   (permalink)
Default

There are times when offloading some functions onto 'glue' hardware is a valid/justifiable design option.

Might actually be better in some cases than the "throw a bigger PIC at the problem" disease (grin)...

Mike



Last edited by Mike, K8LH; 3rd November 2007 at 01:30 AM.
Mike, K8LH is offline  
Old 27th October 2007, 04:22 PM   (permalink)
Default

Your glue logic seems to be a pic!!

Mike.
Pommie is offline  
Old 27th October 2007, 04:33 PM   (permalink)
Default

Quote:
Originally Posted by Pommie
Your glue logic seems to be a pic!!
Glue logic is a very common use for a PIC!.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
Graphic LCD flemmard Micro Controllers 1 13th September 2007 03:32 AM



All times are GMT. The time now is 08:31 PM.


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

eXTReMe Tracker