![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| 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 | |
| |
| | (permalink) |
| 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 HTH Mike. | |
| |
| | (permalink) |
| 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.
__________________ L.Chung | |
| |
| | (permalink) |
| 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. | |
| |
| | (permalink) | |
| Quote:
You cannot read from both at the same time, hence my convoluted TestNotBusy routine. Mike. | ||
| |
| | (permalink) |
| Thanks Guys I Am Going To Give These A Try And Will Get Back To You | |
| |
| | (permalink) | |
| Quote:
__________________ L.Chung | ||
| |
| | (permalink) |
| 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 | |
| |
| | (permalink) |
| 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 | |
| |
| | (permalink) |
| So, you add two extra chips rather than use a bigger pic chip. Mike. | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| 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. | |
| |
| | (permalink) |
| Your glue logic seems to be a pic!! Mike. | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| Graphic LCD | flemmard | Micro Controllers | 1 | 13th September 2007 03:32 AM |