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
 
Thread Tools Display Modes
Old 16th March 2006, 02:25 PM   (permalink)
Default lcd busy code

concerning this code,

Code:
LCD_Busy
		bsf	STATUS,	RP0		;set bank 1
		movlw	0x0f			;set Port for input
		movwf	LCD_TRIS
		bcf	STATUS,	RP0		;set bank 0
		bcf	LCD_PORT, LCD_RS	;set LCD for command mode
		bsf	LCD_PORT, LCD_RW	;setup to read busy flag
		bsf	LCD_PORT, LCD_E
		swapf	LCD_PORT, w		;read upper nibble (busy flag)
		bcf	LCD_PORT, LCD_E		
		movwf	templcd2 
		bsf	LCD_PORT, LCD_E		;dummy read of lower nibble
		bcf	LCD_PORT, LCD_E
		btfsc	templcd2, 7		;check busy flag, high = busy
		goto	LCD_Busy		;if busy check again
		bcf	LCD_PORT, LCD_RW
		bsf	STATUS,	RP0		;set bank 1
		movlw	0x00			;set Port for output
		movwf	LCD_TRIS
		bcf	STATUS,	RP0		;set bank 0
		return


1. why is rs set to command mode?
2.How come it is not set back to symbol mode
3. Why did you swop the intput of lcd port, i changed the code so that it just read bit 3, and it still seems to work, was there any other reason for the swop command

Code:
LCD_Busy
		bsf	STATUS,	RP0		;set bank 1
		movlw	0x0f			;set Port for input
		movwf	LCD_TRIS
		bcf	STATUS,	RP0		;set bank 0
		bcf	LCD_PORT, LCD_RS	;set LCD for command mode
		bsf	LCD_PORT, LCD_RW	;setup to read busy flag
		bsf	LCD_PORT, LCD_E
		movf	LCD_PORT, w		;read upper nibble (busy flag)
		bcf	LCD_PORT, LCD_E		
		movwf	templcd2 
		bsf	LCD_PORT, LCD_E		;dummy read of lower nibble
		bcf	LCD_PORT, LCD_E
		btfsc	templcd2, 3		;check busy flag, high = busy
		goto	LCD_Busy		;if busy check again
		bcf	LCD_PORT, LCD_RW
		bsf	STATUS,	RP0		;set bank 1
		movlw	0x00			;set Port for output
		movwf	LCD_TRIS
		bcf	STATUS,	RP0		;set bank 0
		return
tama182 is offline   Reply With Quote
Old 16th March 2006, 02:32 PM   (permalink)
Default

As it's four bit mode you need two reads to get the 8 bits (although one is a dummy, as it doesn't contain the bit you're checking), so you would normally use 'swapf' for one of the reads - I saw no reason to change it?.

As for command mode, presumably it's required to be in that mode?, it's been many years since I read the datasheet and wrote those routines.

In any case, they work great - and "if it's not broke, don't try and fix it" :lol:
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline   Reply With Quote
Old 17th March 2006, 10:00 PM   (permalink)
Default

As soon as an LCD is turned on, the first line or at least the first 1/2 line will consist of black blocks.

What you need to do is set LCD to command mode, and inject the code into the LCD's data pins so that it is setup properly, and there is a code that turns on the display. Check the HD47780 LCD command set for details.

Once you done eveything right, the bars should disappear. At this point, go to symbol mode and your characters can now be sent.
__________________
-=: The best low-priced components to troubleshoot with are the speaker and the LED :=-
mstechca is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes




All times are GMT. The time now is 11:28 PM.


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