![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Markdem
Joined: 24 Jun 2005 Posts: 206
|
Display problem with GLCD |
Posted: Tue Dec 12, 2006 3:28 am |
|
|
Hi all, i have been working on this problem all night, but cant seem to understand.
I have the following code, with the standed ccs HDM64GS12.c file, just with the output pins changed. I know it works as i have used it on many diffrent projects. Each time i start the PIC, the display will look corrupted. However, each time the loop runs, the display gets better, eg not so corrupted. I can see the text better each time. After about 10 loops, is it OK. If i then turn the power off, and back on, it will still be OK. The olny time it will corrupt again, is if i leave the power off for about 5 min, or reprogram the PIC.
I am using a regulated +5v power supply, which will work with outer projects. I have also tried a diffrent MCU. The olny thing i dont have right now is a nother LCD. Do you think it could be the problem, or is there just somthing i have missed
Code: |
#include <18F4550.h>
#FUSES NOWDT, WDT128, HS, NOPROTECT, BROWNOUT_NOSL, NOBROWNOUT, BORV20, NOPUT, NOCPD, STVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOIESO, NOFCMEN, NOPBADEN, NOWRTC, NOWRTB, NOEBTR, NOEBTRB, NOCPB, MCLR, LPT1OSC, NOXINST, PLL1
#use delay(clock=20000000)
#include <HDM64GS12.c>
#include <graphics.c>
#include <ds1307.c>
char lcddata[20];
int sec, min, hrs, day, mth, year, dow;
void main()
{
int data = 0;
output_high(PIN_E0); //turn on lcd back light
delay_ms(1000);
glcd_init(ON);
delay_ms(2000);
while(1)
{
glcd_fillScreen(off);
data ++;
sprintf(lcddata,"%i",data);
glcd_text57(1,30,lcddata,1,ON);
ds1307_get_time(hrs,min,sec);
sprintf(lcddata,"%02U:%02U",hrs,min);
glcd_rect(6,1,43,8,yes,off);
glcd_text57(6,1,lcddata,1,on);
ds1307_get_date(day,mth,year,dow);
sprintf(lcddata,"%02u/%02u/20%02u",day,mth,year);
glcd_rect(46,10,105,8,yes,off);
glcd_text57(46,10,lcddata,1,on);
delay_ms(500);
}
}
|
Thanks again, Mark |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Dec 12, 2006 3:12 pm |
|
|
Quote: |
I have the following code, with the standard CCS HDM64GS12.c file,
just with the output pins changed.
I know it works as i have used it on many different projects.
|
What is different between your current project and the previous projects ?
1. The compiler version ?
2. The part number of the PIC ?
3. The circuit board and wiring ?
4. Power supply voltage for the PIC ?
5. The brand and part number of the LCD ?
6. The crystal frequency for the PIC ?
If it worked previously and now it doesn't work, then try to find out
which thing that was changed is the cause of the problem. Try to
reduce the total number of changes, so you can find the problem.
For example, if it worked with an older version of the compiler, then
go back to to that version. See if the problem is fixed. |
|
![](templates/subSilver/images/spacer.gif) |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Tue Dec 12, 2006 9:51 pm |
|
|
The driver does not check the status flag. This can cause problems if the LCD is busy when you try and write data to it. You will be missing pixels or have the MSB of the data byte set by mistake. Did your previous project use a slower processor? |
|
![](templates/subSilver/images/spacer.gif) |
someone Guest
|
|
Posted: Wed Dec 13, 2006 12:04 am |
|
|
try increasing the delays in the instruction 'delay_cycles()' in the library file 'HDM64GS12.c'. I hope this help |
|
![](templates/subSilver/images/spacer.gif) |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Wed Dec 13, 2006 7:25 am |
|
|
Here is an example of how to check the busy flag
Code: |
void GLCD_StrobeEnable(void)
{
GLCD_E_SetVal(); // Pulse the enable pin
asm
{
nop
nop
nop
nop
nop
}
GLCD_E_ClrVal(); // Pulse the enable pin
}
void GLCD_WaitBusy(void)
{
uint8_t status;
GLCD_Data_SetDir(FALSE);
GLCD_DI_ClrVal(); // Set for instruction
GLCD_RW_SetVal(); // Set for reading
asm
{
nop
nop
nop
}
while (1)
{
GLCD_E_SetVal(); // Pulse the enable pin
asm
{
nop
nop
nop
nop
nop
}
status = GLCD_Data_GetVal(); // Get the data from the display's output register
GLCD_E_ClrVal();
if ((status & 0x80) == 0)
break;
asm
{
nop
nop
nop
nop
nop
nop
}
}
GLCD_RW_ClrVal(); // Set for reading
}
void GLCD_InstructionWrite(bool side, uint8_t Instruction)
{
if(side) // Choose which side to write to
GLCD_CS2_SetVal();
else
GLCD_CS1_SetVal();
GLCD_WaitBusy();
GLCD_DI_ClrVal(); // Set for instruction
GLCD_Data_SetDir(TRUE);
GLCD_RW_ClrVal(); // clear for writing
GLCD_Data_PutVal(Instruction); // Put the data on the port
GLCD_StrobeEnable();
GLCD_RW_SetVal();
GLCD_Data_SetDir(FALSE);
GLCD_CS1_ClrVal(); // Reset the chip select lines
GLCD_CS2_ClrVal();
}
void GLCD_DataWrite(bool side, uint8_t data)
{
if(side) // Choose which side to write to
GLCD_CS2_SetVal();
else
GLCD_CS1_SetVal();
GLCD_WaitBusy();
GLCD_DI_SetVal(); // Set for data
GLCD_RW_ClrVal(); // clear for writing
GLCD_Data_SetDir(TRUE);
GLCD_Data_PutVal(data); // Put the data on the port
GLCD_StrobeEnable();
GLCD_RW_SetVal();
GLCD_Data_SetDir(FALSE);
GLCD_CS1_ClrVal(); // Reset the chip select lines
GLCD_CS2_ClrVal();
}
uint8_t GLCD_DataRead(bool side)
{
uint8_t data; // Stores the data read from the LCD
GLCD_Data_SetDir(FALSE);
if(side) // Choose which side to write to
GLCD_CS2_SetVal();
else
GLCD_CS1_SetVal();
GLCD_WaitBusy();
GLCD_RW_SetVal(); // Set for reading
GLCD_DI_SetVal(); // Set for data
GLCD_E_SetVal(); // Pulse the enable pin
asm
{
nop
nop
nop
nop
nop
}
data = GLCD_Data_GetVal(); // Get the data from the display's output register
GLCD_E_ClrVal();
GLCD_CS1_ClrVal(); // Reset the chip select lines
GLCD_CS2_ClrVal();
return data; // Return the read data
}
|
Note that the delays in this code are specific to the speed of the processor that I used. I tweaked the values to adhere to the spec and give me the fastest performance. This code is posted as an example of how to implement and not as a replacement for the existiing code. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|