![]() | ![]() | ![]() |
| | #121 |
|
Hello Pommie, it is a great job writing a library like this. Your library is one of the best, most understandable and standard one I have ever come across on the net. Thank you very much for your hard work. I've just started to learn embedded systems with PIC series. Yesterday I wrote my first "Hello World" application which is actually nothing bot blinking a LED. Now I want to put my effort into something bigger, like interfacing an LCD. I have a few question about your code, but first I want to introduce the relevant information I collected over internet... Direct links to photos of my LCD (with KS108 controller): Front, Back Port mapping in you code: Code: #define GLCD_Data PORTD #define b_GLCD_GCS1 LATBbits.LATB4 #define b_GLCD_GCS2 LATCbits.LATC0 #define b_GLCD_RS LATEbits.LATE0 #define b_GLCD_RW LATEbits.LATE1 #define b_GLCD_E LATEbits.LATE2 #define b_GLCD_On LATAbits.LATA4 #define b_GLCD_BL LATBbits.LATB3 KS0108 Controller, at the bottom of the page. Instruction set of the LCD: http://www.stirve.com/storage/lcd_instruction_set_1.jpg Now, the point which confuses me is, Your code defines these 6 connections: b_GLCD_GCS1 b_GLCD_GCS2 b_GLCD_RS b_GLCD_RW b_GLCD_E b_GLCD_On LCD has these 6 pins available: D/I R/W E CS1 CS2 RES If you try to match these: b_GLCD_GCS1 == CS1 b_GLCD_GCS2 == CS2 b_GLCD_RS == RES b_GLCD_RW == R/W b_GLCD_E == E b_GLCD_On == ??? One can say that b_GLCD_On should match with D/I, but when you refer to the instruction set of the LCD, D/I pin is for specifying whether our output data at PIC pins is data or instruction. On the other hand, from my understanding (excuse me if I am wrong), b_GLCD_On is used for some other purpose like activating the LCD, I think you control power source of the LCD, by switching on and off a transistor with this pin. Can you please specify what b_GLCD_On is for, and how you handle D/I pin? Do you have any sample schematics and code? Again, thank you for this wonderful project. I will appreciate if you reply. | |
| |
| | #122 |
|
Double post deleted, sorry for inconvenience...
Last edited by hkBattousai; 31st October 2009 at 11:31 AM. Reason: Double post | |
| |
| | #123 |
|
I think it refers to the RES pin Edited to be correct heh
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics Last edited by AtomSoft; 31st October 2009 at 01:52 PM. | |
| |
| | #124 |
| | |
| |
| | #125 |
|
RS... is D/I GLCD_on is RES
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics Last edited by AtomSoft; 31st October 2009 at 01:53 PM. | |
| |
| | #126 |
|
If you look at his Data and Command code: Code: void GLCD_Write_Cmd(unsigned char data){
Wait_Not_Busy();
GLCD_Data = data;
b_GLCD_RS=0;
b_GLCD_RW=0;
b_GLCD_E=1;
Delay();
b_GLCD_E=0;
}
void GLCD_Write_Data (unsigned char data){
Wait_Not_Busy();
GLCD_Data = data;
b_GLCD_RS=1;
b_GLCD_RW=0;
b_GLCD_E=1;
Delay();
b_GLCD_E=0;
}
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #127 |
| | |
| |
| | #128 |
|
#define b_TRIS_On TRISAbits.TRISA4 //RST so b_GLCD_On is the RS pin on GLCD
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #129 |
|
Heh i confuse people maybe so here is the code commented to clarify what i mean: Code: #define GLCD_Data PORTD //DB0 to DB7 #define b_GLCD_GCS1 LATBbits.LATB4 //Chip Select 1 #define b_GLCD_GCS2 LATCbits.LATC0 //Chip Select 2 #define b_GLCD_RS LATEbits.LATE0 //GLCD D/I #define b_GLCD_RW LATEbits.LATE1 //GLCD R/W #define b_GLCD_E LATEbits.LATE2 //GLCD E #define b_GLCD_On LATAbits.LATA4 //GLCD RES #define b_GLCD_BL LATBbits.LATB3 //GLCD Backlight #define TRIS_Data TRISD //TRIS for DB0 to DB7 #define b_TRIS_GCS1 TRISBbits.TRISB4 //GCS1 #define b_TRIS_GCS2 TRISCbits.TRISC0 //GCS2 #define b_TRIS_RS TRISEbits.TRISE0 //D/I #define b_TRIS_RW TRISEbits.TRISE1 //RW #define b_TRIS_E TRISEbits.TRISE2 //E #define b_TRIS_On TRISAbits.TRISA4 //RES #define b_TRIS_BL TRISBbits.TRISB3 //backlight
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics Last edited by AtomSoft; 31st October 2009 at 01:52 PM. | |
| |
| | #130 |
|
^ This comments explain everything ![]() But now, there is this new term: "RES". Correct me if I'm wrong, RS == D/I RES == RST == Reset Is that right? | |
| |
| | #131 |
|
YES heh you got it now Code: #define GLCD_Data PORTD //DB0 to DB7 #define b_GLCD_GCS1 LATBbits.LATB4 //Chip Select 1 #define b_GLCD_GCS2 LATCbits.LATC0 //Chip Select 2 #define b_GLCD_RS LATEbits.LATE0 //GLCD RS,D/I #define b_GLCD_RW LATEbits.LATE1 //GLCD R/W #define b_GLCD_E LATEbits.LATE2 //GLCD E #define b_GLCD_On LATAbits.LATA4 //GLCD RES,RST,RESET #define b_GLCD_BL LATBbits.LATB3 //GLCD Backlight #define TRIS_Data TRISD //TRIS for DB0 to DB7 #define b_TRIS_GCS1 TRISBbits.TRISB4 //GCS1 #define b_TRIS_GCS2 TRISCbits.TRISC0 //GCS2 #define b_TRIS_RS TRISEbits.TRISE0 //RS, D/I #define b_TRIS_RW TRISEbits.TRISE1 //RW #define b_TRIS_E TRISEbits.TRISE2 //E #define b_TRIS_On TRISAbits.TRISA4 //RES,RST,RESET #define b_TRIS_BL TRISBbits.TRISB3 //backlight
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics Last edited by AtomSoft; 31st October 2009 at 02:09 PM. | |
| |
| | #132 |
|
Below are the pieces of code which I modified or appended: glcd.h Code: #include <p18f2550.h> #define GLCD_Data PORTB #define b_GLCD_GCS1 LATCbits.LATC7 #define b_GLCD_GCS2 LATCbits.LATC6 #define b_GLCD_RS LATCbits.LATC0 #define b_GLCD_RW LATCbits.LATC1 #define b_GLCD_E LATAbits.LATA5 #define b_GLCD_On LATCbits.LATC2 #define b_GLCD_BL LATAbits.LATA4 // Not used in my project #define TRIS_Data TRISB #define b_TRIS_GCS1 TRISCbits.TRISC7 //GCS1 #define b_TRIS_GCS2 TRISCbits.TRISC6 //GCS2 #define b_TRIS_RS TRISCbits.TRISC0 //RS #define b_TRIS_RW TRISCbits.TRISC1 //RW #define b_TRIS_E TRISAbits.TRISA5 //E #define b_TRIS_On TRISCbits.TRISC2 //RST #define b_TRIS_BL TRISAbits.TRISA4 //backlight Code: void Delay(void){
_asm NOP _endasm
_asm NOP _endasm
_asm NOP _endasm
_asm NOP _endasm
_asm NOP _endasm
_asm NOP _endasm
_asm NOP _endasm
_asm NOP _endasm
_asm NOP _endasm
_asm NOP _endasm
}
I didn't change any other function in this file (Except for replacing "#include <p18f4550.h>" with "#include <p18f2550.h>").) main.c Code: #include <p18f2550.h>
#include "glcd.h"
#pragma config WDT = OFF
#pragma config MCLRE = ON
#pragma config DEBUG = OFF
#pragma config LVP = OFF
#pragma config PLLDIV = 5 // need 5 for 20MHz xtal
#pragma config CPUDIV = OSC1_PLL2 // CPU Clock = 96 MHz/2 = 48 MHz
#pragma config USBDIV = 2 // 96MHz PLL/2 = 48 MHz for USB clock
#pragma config FOSC = HSPLL_HS // High Speed Crystal / Resonator with PLL enabled
void main (void)
{
while (1) // Nothing changes if I remove this infinite loop
{
Init_GLCD();
PutMessage((rom char*)"\x16\x24\x08 Blueroom\x16\x20\x10 Electronics\n Title:\n Author:\n Date:\n Hardware:");
PutMessage((rom char*)"\x16\x38\x18Graphic demo.");
PutMessage((rom char*)"\x16\x38\x20Mike Webb.");
PutMessage((rom char*)"\x16\x38\x28June 20 2007.");
PutMessage((rom char*)"\x16\x38\x30Unicorn.");
box(1,1,126,62);
}
while (1);
// Working "Hello World" example
/*unsigned char i, j;
TRISB = 0;
while (1)
{
PORTB = 0x00;
Delay1KTCYx(i);
PORTB = 0xFF;
Delay1KTCYx(255-i);
}*/
}
Front, Up I checked signal levels at PIC pins with an oscilloscope and everything looks alright. OSC1 and OSC2 has clock pulses; data port, and other relevant LCD pins have meaningful pulses. I think it is likely that there has to be mistake in my code. And, I found a new datasheet (uploaded as an attachment) for my LCD, and after reading it I realized that the pin configurations in my first post in this thread was wrong. I rebuilt the circuit by refering to this new datasheet; yet it still isn't working... I'm totally stuck! Last edited by hkBattousai; 31st October 2009 at 10:52 PM. | |
| |
| | #133 |
|
Move the init out the while loop first of all I'll take a look at it closer in a minute ...can u post a schematic for me just for fun
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #134 | |
| Quote:
Unfortunately I didn't use any schematics, actually I couldn't find any schematics. I built up the circuit on a bread-board (the one you see in the link in my previous message) just by looking at PIC and LCD datasheet. | ||
| |
| | #135 | |
|
I read some datasheet about "xG12864x-xxx-x" LCD unit. I realized a point, pin configuration differs for every product. Even if the you manage to catch the rightful pin locations and match them perfectly between PIC and LCD, you system could not work because some pins may be complemented on the LCD side. For example, In "Crystalfontz America" model (CFAG12864B-WGH-V) CS1 and CS2 bits are complemented, while in "Winstar" model (WG12864B) CS1 and CS2 bits are not complemented. This was just an example, there are more that CSx bits that differ. For example E (Enable) is complemented in some LCDs, and not complemented in others. I really need a detailed pin configuration from one of you who succeeded in this project. I need to know:
************ Quote:
This would help greatly if you answer this question. | ||
| |
|
| Tags |
| demo, glcd, unicorn |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| Unicorn Oscilloscope running GLCD 128x64 & Photo | blueroomelectronics | Micro Controllers | 8 | 18th June 2007 03:06 PM |
| Help understanding the Unicorn | Kyle-s4h | Micro Controllers | 2 | 5th June 2007 07:09 PM |
| Open MultiSim DEMO Files | mayo | General Electronics Chat | 1 | 3rd May 2007 04:52 PM |
| mcuStudio an Eclipse based IDE for PIC: flash demo available | octal | Micro Controllers | 0 | 23rd August 2006 06:44 AM |
| Honeywell HMR3000 DEMO KIT | shermaine | General Electronics Chat | 5 | 26th May 2005 09:35 AM |