CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

S1D13305 driver will not work
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

S1D13305 driver will not work
PostPosted: Mon Nov 12, 2007 1:46 pm     Reply with quote

I have the following test lines.
The display initialize with a blue screen
after display_ON the whole screen are filled with random pixels

The line glcd_fillscreentext(' ') should clear the screen, but it did't

I'm now 3 days working with it, but no go.

Wo can help me??

Code:

#include <18F4620.h>
#use delay(clock=20000000)
#fuses HS,NOWDT,NOBROWNOUT,NOPUT,NOLVP,DEBUG,NOSTVREN,NOPROTECT

#define GLCD_WIDTH        320
#define GLCD_HEIGHT       240
#define GLCD_CHAR_WIDTH   8
#define GLCD_CHAR_HEIGHT  8
#define ON                 1
#define OFF                0

#define GLCD_RST          PIN_B3
#define GLCD_RD           PIN_B0
#define GLCD_WR           PIN_B1
#define GLCD_CS           PIN_B4
#define GLCD_A0           PIN_B2

#define GLCD_CMD_SYSTEM         0x40  // General system settings
#define GLCD_CMD_SLEEP          0x53  // Enter into standy mode
#define GLCD_CMD_DISP_OFF       0x58  // Turn the display off
#define GLCD_CMD_DISP_ON        0x59  // Turn the display on
#define GLCD_CMD_SCROLL         0x44  // Setup text and graphics address regions
#define GLCD_CMD_CSR_FORM       0x5D  // Set cursor size
#define GLCD_CMD_CGRAM_ADDR     0x5C  // Configure character generator RAM address
#define GLCD_CMD_CSRDIR_RIGHT   0x4C  // Cursor moves right after write to display memory
#define GLCD_CMD_CSRDIR_LEFT    0x4D  // Cursor moves left after write to display memory
#define GLCD_CMD_CSRDIR_UP      0x4E  // Cursor moves up after write to display memory
#define GLCD_CMD_CSRDIR_DN      0x4F  // Cursor moves down after write to display memory
#define GLCD_CMD_HDOT_SCR       0x5A  // Set horizontal scroll rate
#define GLCD_CMD_OVERLAY        0x5B  // Configure how layers overlay
#define GLCD_CMD_SET_CSR_ADDR   0x46  // Set the cursor address
#define GLCD_CMD_GET_CSR_ADDR   0x47  // Read the cursor address
#define GLCD_CMD_DISPLAY_WRITE  0x42  // Write to display memory
#define GLCD_CMD_DISPLAY_READ   0x43  // Read from display memory

void lcd_write_data(byte data)
{
    output_c(data);
   output_low(GLCD_CS);
   delay_cycles(1);
   output_low(GLCD_WR);
   delay_cycles(2);
   output_high(GLCD_WR);
   output_high(GLCD_CS);
}

void lcd_write_cmd(int8 command)
{
   output_high(GLCD_A0);
   lcd_write_data(command);
}

void display(int1 mode)
{
   if(mode == ON)
   {
      lcd_write_cmd(GLCD_CMD_DISP_ON);
   }
   else
   {
      lcd_write_cmd(GLCD_CMD_DISP_OFF);
   }
   output_low(GLCD_A0);
   lcd_write_data(0x14);
}

void setCursorAddress(int16 addr)
{
   lcd_write_cmd(GLCD_CMD_SET_CSR_ADDR);
   output_low(GLCD_A0);
   lcd_write_data(*(int8*)(&addr   ));
   lcd_write_data(*(int8*)(&addr + 1));
}

void glcd_fillScreenText(char c)
{
   int16 i;

   setCursorAddress(0x0000);
   lcd_write_cmd(GLCD_CMD_DISPLAY_WRITE);
   output_low(GLCD_A0);

   for(i = 0x0000; i < 1200; ++i)
   {
      lcd_write_data(c);
   }
}

void main() {
   output_high(GLCD_RST);
   output_high(GLCD_CS);
   output_high(GLCD_RD);
   output_high(GLCD_WR);
   
   lcd_write_cmd(GLCD_CMD_SYSTEM);
   output_low(GLCD_A0);
      lcd_write_data(0x30);
      lcd_write_data(0x87);
      lcd_write_data(0x07);
      lcd_write_data(0x27);
      lcd_write_data(0x42);
      lcd_write_data(0xEF);
      lcd_write_data(0x28);
      lcd_write_data(0x00);
      
      lcd_write_cmd(GLCD_CMD_SCROLL);
      output_low(GLCD_A0);
      lcd_write_data(0x00);
      lcd_write_data(0x00);
      lcd_write_data(0xEF);
      lcd_write_data(0x60);
      lcd_write_data(0x09);
      lcd_write_data(0xEF);
      lcd_write_data(0x00);
      lcd_write_data(0x00);
      lcd_write_data(0x00);
      lcd_write_data(0x00);
      
      lcd_write_cmd(GLCD_CMD_HDOT_SCR);
      output_low(GLCD_A0);
      lcd_write_data(0x00);

      lcd_write_cmd(GLCD_CMD_OVERLAY);
      output_low(GLCD_A0);
      lcd_write_data(0x01);

   display(OFF);
   
      lcd_write_cmd(GLCD_CMD_CSR_FORM);
      output_low(GLCD_A0);
      lcd_write_data(0x07);
      lcd_write_data(0x87);
      
      display(ON);
      
      lcd_write_cmd(GLCD_CMD_CSRDIR_RIGHT);
      
      glcd_fillscreentext(' ');

}
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Nov 12, 2007 2:14 pm     Reply with quote

Here is simple example of init proc
Did't also work for me Sad Sad Sad


Code:
#include <18F4620.h>
#use delay(clock=20000000)
#fuses HS,NOWDT,NOBROWNOUT,NOPUT,NOLVP,DEBUG,NOSTVREN,NOPROTECT

#define GLCD_WIDTH        320
#define GLCD_HEIGHT       240
#define GLCD_CHAR_WIDTH   8
#define GLCD_CHAR_HEIGHT  8
#define ON                 1
#define OFF                0

#define GLCD_RST          PIN_B3
#define GLCD_RD           PIN_B0
#define GLCD_WR           PIN_B1
#define GLCD_CS           PIN_B4
#define GLCD_A0           PIN_B2

#define GLCD_CMD_SYSTEM         0x40  // General system settings
#define GLCD_CMD_SLEEP          0x53  // Enter into standy mode
#define GLCD_CMD_DISP_OFF       0x58  // Turn the display off
#define GLCD_CMD_DISP_ON        0x59  // Turn the display on
#define GLCD_CMD_SCROLL         0x44  // Setup text and graphics address regions
#define GLCD_CMD_CSR_FORM       0x5D  // Set cursor size
#define GLCD_CMD_CGRAM_ADDR     0x5C  // Configure character generator RAM address
#define GLCD_CMD_CSRDIR_RIGHT   0x4C  // Cursor moves right after write to display memory
#define GLCD_CMD_CSRDIR_LEFT    0x4D  // Cursor moves left after write to display memory
#define GLCD_CMD_CSRDIR_UP      0x4E  // Cursor moves up after write to display memory
#define GLCD_CMD_CSRDIR_DN      0x4F  // Cursor moves down after write to display memory
#define GLCD_CMD_HDOT_SCR       0x5A  // Set horizontal scroll rate
#define GLCD_CMD_OVERLAY        0x5B  // Configure how layers overlay
#define GLCD_CMD_SET_CSR_ADDR   0x46  // Set the cursor address
#define GLCD_CMD_GET_CSR_ADDR   0x47  // Read the cursor address
#define GLCD_CMD_DISPLAY_WRITE  0x42  // Write to display memory
#define GLCD_CMD_DISPLAY_READ   0x43  // Read from display memory

void lcd_write_data(byte data)
{
   output_c((data));
   output_low(GLCD_CS);
   delay_cycles(1);
   output_low(GLCD_WR);
   delay_cycles(2);
   output_high(GLCD_WR);
   output_high(GLCD_CS);
}

void lcd_write_cmd(int8 command)
{
   output_high(GLCD_A0);
   lcd_write_data(command);
}

void main() {
   output_high(GLCD_RST);
   output_HIGH(GLCD_CS);
   output_high(GLCD_RD);
   output_high(GLCD_WR);

   lcd_write_cmd(GLCD_CMD_SYSTEM);
   output_low(GLCD_A0);
      lcd_write_data(0x30);
      lcd_write_data(0x87);
      lcd_write_data(0x00);
      lcd_write_data(0x28);
      lcd_write_data(0x45);
      lcd_write_data(0xEF);
      lcd_write_data(0x28);
      lcd_write_data(0x00);
      
      lcd_write_cmd(GLCD_CMD_SCROLL);
      output_low(GLCD_A0);
      lcd_write_data(0x00);
      lcd_write_data(0x00);
      lcd_write_data(0xEF);
      lcd_write_data(0x00);
      lcd_write_data(0x00);
      lcd_write_data(0xEF);
      lcd_write_data(0x00);
      lcd_write_data(0x00);
      lcd_write_data(0x00);
      lcd_write_data(0x00);
      
      lcd_write_cmd(GLCD_CMD_HDOT_SCR);
      output_low(GLCD_A0);
      lcd_write_data(0x00);

      lcd_write_cmd(GLCD_CMD_OVERLAY);
      output_low(GLCD_A0);
      lcd_write_data(0x01);

   lcd_write_cmd(GLCD_CMD_DISP_OFF);
      output_low(GLCD_A0);
      lcd_write_data(0x16);

   lcd_write_cmd(GLCD_CMD_DISPLAY_WRITE);
      output_low(GLCD_A0);
      lcd_write_data(0x20);
   
      lcd_write_cmd(GLCD_CMD_DISPLAY_WRITE);
      output_low(GLCD_A0);
      lcd_write_data(0x00);

      lcd_write_cmd(GLCD_CMD_SET_CSR_ADDR);
      output_low(GLCD_A0);
      lcd_write_data(0x00);
    lcd_write_data(0x00);
   
      lcd_write_cmd(GLCD_CMD_CSR_FORM);
      output_low(GLCD_A0);
      lcd_write_data(0x04);
      lcd_write_data(0x86);
      
    lcd_write_cmd(GLCD_CMD_DISP_ON);
      output_low(GLCD_A0);
      lcd_write_data(0x16);

   lcd_write_cmd(GLCD_CMD_CSRDIR_RIGHT);
   
   lcd_write_cmd(GLCD_CMD_DISPLAY_WRITE );
      output_low(GLCD_A0);
      lcd_write_data(0x45);

 }
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 12, 2007 2:46 pm     Reply with quote

For some reason, you changed a lot of the setup values from the
standard values to some strange ones. I don't know why you did this,
but that's probably why it doesn't work.
Quote:
lcd_write_cmd(GLCD_CMD_SYSTEM);
output_low(GLCD_A0);
lcd_write_data(0x30);
lcd_write_data(0x87);
lcd_write_data(0x00); // Other drivers use 0x07
lcd_write_data(0x28); // Other drivers use 0x27
lcd_write_data(0x45); // Other drivers use 0x38
lcd_write_data(0xEF);
lcd_write_data(0x28);
lcd_write_data(0x00);


Quote:
lcd_write_cmd(GLCD_CMD_SCROLL);
output_low(GLCD_A0);
lcd_write_data(0x00);
lcd_write_data(0x00);
lcd_write_data(0xEF);
lcd_write_data(0x60); // Other drivers use 0xB0
lcd_write_data(0x09); // Other drivers use 0x04
lcd_write_data(0xEF);
lcd_write_data(0x00);
lcd_write_data(0x00);
lcd_write_data(0x00);
lcd_write_data(0x00);

The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Nov 12, 2007 4:03 pm     Reply with quote

both settings doesn't work Sad
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Nov 13, 2007 4:39 pm     Reply with quote

Nobody can help Crying or Very sad Crying or Very sad

Then can go the lcd to the recycle bin
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Nov 15, 2007 3:15 pm     Reply with quote

Double check your hardware connections.
Have you placed a 47uF close to pin 1 and 2 of the LCD connector?

You are using port C as the data port. Double check you have connected these pins correctly to the LCD (no changed wires, etc).

By default the PORTB pins are configured as analog inputs on power up. I don't see code to change the to digital I/O pins (add the PBADEN fuse or call SETUP_ADC_PORTS(NO_ANALOGS) ).

According to the datasheet all pins on PORTC should be configured as digital input on power up, but it doesn't hurt to explicitely disable all multiplexed devices on these pins:
Code:
SETUP_CCP1(CCP_OFF);
SETUP_CCP2(CCP_OFF);
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Nov 15, 2007 3:54 pm     Reply with quote

I have added these instructions but nog go

Code:
void glcd_init(int1 mode) {
   output_high(GLCD_RST);
   output_high(GLCD_CS);
   output_high(GLCD_RD);
   output_high(GLCD_WR);
   
   glcd_systemSetup();
   glcd_scrollSetup();
   glcd_overlaySetup();
   glcd_power(OFF);
   glcd_cursorForm(4,6);
   glcd_fillScreen(OFF);
   glcd_fillScreenText(' ');
   glcd_power(mode);
   glcd_cursorDirection(GLCD_CMD_CSRDIR_RIGHT);
}


I have stepped to the code
to the instruction glcd_power(mode) the screen is blue with a ligher blue around.
This is good in my opinium, but after the glcd_power instruction i get randomized dot pattern.
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Nov 15, 2007 4:04 pm     Reply with quote

Why dit this code not work?
I get only garbage on the screen

Code:
////////////////////////////////////////////////////////////////////////////
#ifndef S1D13305
#define S1D13305

#ifndef GLCD_WIDTH
#define GLCD_WIDTH        320
#endif

#ifndef GLCD_HEIGHT
#define GLCD_HEIGHT       240
#endif

#ifndef GLCD_CHAR_WIDTH
#define GLCD_CHAR_WIDTH   8
#endif

#ifndef GLCD_CHAR_HEIGHT
#define GLCD_CHAR_HEIGHT  8
#endif

#ifndef GLCD_RST
#define GLCD_RST          PIN_D4
#endif

#ifndef GLCD_RD
#define GLCD_RD           PIN_D0
#endif

#ifndef GLCD_WR
#define GLCD_WR           PIN_D1
#endif

#ifndef GLCD_CS
#define GLCD_CS           PIN_D3
#endif

#ifndef GLCD_A0
#define GLCD_A0           PIN_D2
#endif

#ifndef ON
#define ON                1
#endif

#ifndef OFF
#define OFF               0
#endif
////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////
// The following defines setup the memory used by different regions
// Currenty one text area is defined at the beginning of memory
// and a graphics area follows immediately after
////////////////////////////////////////////////////////////////////////////
#define GLCD_TEXT_ADDR          0x0000
#define GLCD_GRAPHICS_ADDR      GLCD_WIDTH*GLCD_HEIGHT/64
#define GLCD_GRAPHICS_ADDR_END  GLCD_GRAPHICS_ADDR+(GLCD_WIDTH*GLCD_HEIGHT/8)
////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////
#if GLCD_CHAR_WIDTH<9
   #define GLCD_CR (GLCD_WIDTH/8-1)
#else
   #define GLCD_CR (GLCD_WIDTH/4-2)
#endif
////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////
#define TGLCD_COMMAND  output_high(GLCD_A0);
#define TGLCD_DATA     output_low(GLCD_A0);
////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////
int8 glcd_readByte();
void glcd_sendByte(int8 data);
void glcd_fillScreen(int1 color);
void glcd_fillScreenText(char c);
void setCursorAddress(int16 addr);
void glcd_pixel(int16 x,int16 y,int1 color);
int8 getData(int16 addr);
void glcd_sendCMD(int8 cmd);
////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////
void glcd_systemSetup();
void glcd_scrollSetup();
void glcd_overlaySetup();
void glcd_power(int1 mode);
void glcd_cursorDirection(int8 dir);
void glcd_cursorForm(int8 width,int8 height);
void setData(int16 addr,int8 data);
////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////
#define GLCD_CMD_SYSTEM         0x40  // General system settings
#define GLCD_CMD_SLEEP          0x53  // Enter into standy mode
#define GLCD_CMD_DISP_OFF       0x58  // Turn the display off
#define GLCD_CMD_DISP_ON        0x59  // Turn the display on
#define GLCD_CMD_SCROLL         0x44  // Setup text and graphics address regions
#define GLCD_CMD_CSR_FORM       0x5D  // Set cursor size
#define GLCD_CMD_CGRAM_ADDR     0x5C  // Configure character generator RAM address
#define GLCD_CMD_CSRDIR_RIGHT   0x4C  // Cursor moves right after write to display memory
#define GLCD_CMD_CSRDIR_LEFT    0x4D  // Cursor moves left after write to display memory
#define GLCD_CMD_CSRDIR_UP      0x4E  // Cursor moves up after write to display memory
#define GLCD_CMD_CSRDIR_DN      0x4F  // Cursor moves down after write to display memory
#define GLCD_CMD_HDOT_SCR       0x5A  // Set horizontal scroll rate
#define GLCD_CMD_OVERLAY        0x5B  // Configure how layers overlay
#define GLCD_CMD_SET_CSR_ADDR   0x46  // Set the cursor address
#define GLCD_CMD_GET_CSR_ADDR   0x47  // Read the cursor address
#define GLCD_CMD_DISPLAY_WRITE  0x42  // Write to display memory
#define GLCD_CMD_DISPLAY_READ   0x43  // Read from display memory
////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////
// Purpose:       Initialize the controller
// Inputs:        The initialization mode
//                OFF - Turns the LCD off
//                ON  - Turns the LCD on
////////////////////////////////////////////////////////////////////////////
void glcd_init(int1 mode) {
   output_high(GLCD_RST);
   output_high(GLCD_CS);
   output_high(GLCD_RD);
   output_high(GLCD_WR);
   
   glcd_systemSetup();
   glcd_scrollSetup();
   glcd_overlaySetup();
   glcd_power(OFF);
   glcd_cursorForm(4,6);
   glcd_fillScreen(OFF);
   glcd_fillScreenText(' ');
   glcd_power(mode);
   glcd_cursorDirection(GLCD_CMD_CSRDIR_RIGHT);
}

////////////////////////////////////////////////////////////////////////////
// Purpose:       Turn a pixel on a graphic LCD on or off
// Inputs:        x     - the x coordinate of the pixel
//                y     - the y coordinate of the pixel
//                color - ON or OFF
////////////////////////////////////////////////////////////////////////////
void glcd_pixel(int16 x,int16 y,int1 color) {
   int8 data;
   int16 addr;
   
   addr=GLCD_GRAPHICS_ADDR+(GLCD_WIDTH/8*y+x/8);
   data=getData(addr);
   
   if(color==ON)
      bit_set(data,7-x%8);
   else
      bit_clear(data,7-x%8);
      
   setData(addr,data);
}

////////////////////////////////////////////////////////////////////////////
// Purpose:    Initialize the display environment
////////////////////////////////////////////////////////////////////////////
void glcd_systemSetup() {
   glcd_sendCMD(GLCD_CMD_SYSTEM);        // Setup the system
   TGLCD_DATA                            // Set for data
   glcd_sendByte(0x30);                  // No offset
   glcd_sendByte(0x7F+GLCD_CHAR_WIDTH);  // Set character width
   glcd_sendByte(GLCD_CHAR_HEIGHT-1);    // Set character height
   glcd_sendByte(GLCD_CR);               // Display line address range
   glcd_sendByte(0x2F);                  // TC/R
   glcd_sendByte(GLCD_HEIGHT-1);         // Number of lines per frame
   glcd_sendByte(GLCD_CR+1);             // Horizontal address range LSB (APL)
   glcd_sendByte((GLCD_CR+1)/0xFF);      // Horizontal address range MSB (APH)
}

////////////////////////////////////////////////////////////////////////////
// Purpose:    Set the scroll start address and
//             the size of a scroll block
////////////////////////////////////////////////////////////////////////////
void glcd_scrollSetup() {
   glcd_sendCMD(GLCD_CMD_SCROLL);           // Setup scrolling
   TGLCD_DATA                               // Set for data
   glcd_sendByte(GLCD_TEXT_ADDR);           // SAD1L
   glcd_sendByte(GLCD_TEXT_ADDR/0xFF);      // SAD1H
   glcd_sendByte(GLCD_HEIGHT-1);            // SL1
   glcd_sendByte(GLCD_GRAPHICS_ADDR);       // SAD2L
   glcd_sendByte(GLCD_GRAPHICS_ADDR/0xFF);  // SAD2H
   glcd_sendByte(GLCD_HEIGHT-1);            // SL2
   glcd_sendByte(0x00);                     // SAD3L
   glcd_sendByte(0x00);                     // SAD3H
   glcd_sendByte(0x00);                     // SAD4L
   glcd_sendByte(0x00);                     // SAD4H
   glcd_sendCMD(GLCD_CMD_HDOT_SCR);         // Horizontal scroll rate
   TGLCD_DATA                               // Set for data
   glcd_sendByte(0x00);                     // Horizontal pixel shift is 0
}

////////////////////////////////////////////////////////////////////////////
// Purpose:    Setup the overlay functionality for combining
//             layers of text and graphics, or multiple
//             graphics layers
////////////////////////////////////////////////////////////////////////////
void glcd_overlaySetup() {
   glcd_sendCMD(GLCD_CMD_OVERLAY);  // Text/graphic overlay mode
   TGLCD_DATA                       // Set for data
   glcd_sendByte(0x09);             // Area 1 text, others graphics
                                    // Text XOR Graphics
}

////////////////////////////////////////////////////////////////////////////
// Purpose:    Turn the display on or off
// Inputs:     ON to turn on or OFF to turn off
////////////////////////////////////////////////////////////////////////////
void glcd_power(int1 mode) {
   if(mode==ON) {
      glcd_sendCMD(GLCD_CMD_DISP_ON);
   }
   else {
      glcd_sendCMD(GLCD_CMD_DISP_OFF);
   }
   TGLCD_DATA
   glcd_sendByte(0x14);
}

////////////////////////////////////////////////////////////////////////////
// Purpose:    Set the direction the cursor moves after
//             writing to dispaly memory
// Inputs:     Use one of the following to set the direction:
//             GLCD_CMD_CSRDIR_RIGHT
//             GLCD_CMD_CSRDIR_LEFT
//             GLCD_CMD_CSRDIR_UP
//             GLCD_CMD_CSRDIR_DOWN
////////////////////////////////////////////////////////////////////////////
void glcd_cursorDirection(int8 dir) {
   glcd_sendCMD(dir);
}

////////////////////////////////////////////////////////////////////////////
// Purpose:    Set the size of the cursor
// Inputs:     1) The width in pixels  - 1  Valid numbers: (0 - 15)
//             2) The height in pixels - 1  Valid numbers: (1 - 15)
////////////////////////////////////////////////////////////////////////////
void glcd_cursorForm(int8 width,int8 height) {
   glcd_sendCMD(GLCD_CMD_CSR_FORM);
   TGLCD_DATA
   glcd_sendByte(width);
   glcd_sendByte(0x80+height);
}

////////////////////////////////////////////////////////////////////////////
// Purpose:    Fill a graphics layer passed in color
//             Works much faster than drawing a rectangle to fill the screen
// Inputs:     ON  - turn all the pixels on
//             OFF - turn all the pixels off
////////////////////////////////////////////////////////////////////////////
void glcd_fillScreen(int1 color) {
   int16 i;
   
   setCursorAddress(GLCD_GRAPHICS_ADDR);
   glcd_sendCMD(GLCD_CMD_DISPLAY_WRITE);
   TGLCD_DATA
   for(i=GLCD_GRAPHICS_ADDR;i<GLCD_GRAPHICS_ADDR_END;++i) {
      glcd_sendByte(0xFF*color);
   }
}

////////////////////////////////////////////////////////////////////////////
// Purpose:    Fill a text layer with a the passed in character
//             Works much faster than drawing a rectangle to fill the screen
// Inputs:     ON  - turn all the pixels on
//             OFF - turn all the pixels off
////////////////////////////////////////////////////////////////////////////
void glcd_fillScreenText(char c) {
   int16 i;
   
   setCursorAddress(GLCD_TEXT_ADDR);
   glcd_sendCMD(GLCD_CMD_DISPLAY_WRITE);
   TGLCD_DATA
   for(i=GLCD_TEXT_ADDR;i<GLCD_GRAPHICS_ADDR;++i) {
      glcd_sendByte(c);
   }
}

////////////////////////////////////////////////////////////////////////////
// Purpose:    Write a byte of data
// Inputs:     The byte of data to write
////////////////////////////////////////////////////////////////////////////
void glcd_sendByte(byte data) {
   output_c((data));
   output_low(GLCD_CS);
   delay_cycles(1);
   output_low(GLCD_WR);
   delay_cycles(2);
   output_high(GLCD_WR);
   output_high(GLCD_CS);
}

////////////////////////////////////////////////////////////////////////////
// Purpose:    Read a byte of data
// Outputs:    The byte of data
////////////////////////////////////////////////////////////////////////////
int8 glcd_readByte() {
   int8 data;
   
   set_tris_c(0xFF);
   output_low(GLCD_CS);
   delay_cycles(1);
   output_low(GLCD_RD);
   delay_cycles(2);
   data=input_c();
   output_high(GLCD_RD);
   output_high(GLCD_CS);
   
   return data;
}

////////////////////////////////////////////////////////////////////////////
// Purpose:    Get the status
// Outputs:    The status in an 8 bit integer
////////////////////////////////////////////////////////////////////////////
int8 getStatus() {
   int8 status;
   
   TGLCD_DATA
   set_tris_c(0xFF);
   output_low(GLCD_CS);
   output_low(GLCD_RD);
   delay_us(1);
   status=input_c();
   output_high(GLCD_RD);
   output_high(GLCD_CS);
   
   return status;
}

////////////////////////////////////////////////////////////////////////////
// Purpose:    Get the current address of the cursor
// Outputs:    A 16 bit integer containing the cursor address
////////////////////////////////////////////////////////////////////////////
int16 getCursorAddress() {
   int16 addr;
   
   glcd_sendCMD(GLCD_CMD_GET_CSR_ADDR);
   TGLCD_DATA
   *(int8*)(&addr)=glcd_readByte();
   *(int8*)(&addr+1)=glcd_readByte();
   
   return addr;
}

////////////////////////////////////////////////////////////////////////////
// Purpose:    Set the cursor address
// Inputs:     A 16 bit integer containing the new cursor address
////////////////////////////////////////////////////////////////////////////
void setCursorAddress(int16 addr) {
   glcd_sendCMD(GLCD_CMD_SET_CSR_ADDR);
   TGLCD_DATA
   glcd_sendByte(*(int8*)(&addr));
   glcd_sendByte(*(int8*)(&addr+1));
}

////////////////////////////////////////////////////////////////////////////
// Purpose:    Get a byte of data from the display at the address
// Inputs:     A 16 bit integer containing the address
// Outputs:    An 8 bit integer with the read data
////////////////////////////////////////////////////////////////////////////
int8 getData(int16 addr) {
   setCursorAddress(addr);
   glcd_sendCMD(GLCD_CMD_DISPLAY_READ);
   TGLCD_DATA
   
   return glcd_readByte();
}

////////////////////////////////////////////////////////////////////////////
// Purpose:    Set a byte of display data at an address
// Inputs:     1) A 16 bit address
//             2) 8 bits worth
////////////////////////////////////////////////////////////////////////////
void setData(int16 addr, int8 data) {
   setCursorAddress(addr);
   glcd_sendCMD(GLCD_CMD_DISPLAY_WRITE);
   TGLCD_DATA
   glcd_sendByte(data);
}

////////////////////////////////////////////////////////////////////////////
// Purpose:    Send an 8 bit command
// Inputs:     The command to send
////////////////////////////////////////////////////////////////////////////
void glcd_sendCMD(int8 cmd) {
   TGLCD_COMMAND
   glcd_sendByte(cmd);
}

#endif

Code:
#include <18F4620.h>
#use delay(clock=20000000)
#fuses HS,NOWDT,NOBROWNOUT,NOPUT,NOLVP,DEBUG,NOSTVREN,NOPROTECT

#include <s1d13305.h>
#include <graphics.h>

void main() {
   glcd_init(ON);   
   glcd_fillScreenText('A');
}
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Nov 16, 2007 5:42 pm     Reply with quote

With mode of the lcd must be used (8080 or 6800 mode)

With mode is compatible with the PIC18F4620??
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Nov 16, 2007 5:58 pm     Reply with quote

The GLCD driver uses RD and WR signals. That's the 8080 mode.
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Sat Nov 17, 2007 2:13 am     Reply with quote

Ok, then is that not the problem

Both pins SEL1 en SEL2 go to the ground
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sat Nov 17, 2007 8:35 am     Reply with quote

[spam],
I gave you some hints, including improved initialisation of Port C (your data port). Did you miss my post or is there something you don't understand?
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Sat Nov 17, 2007 9:31 am     Reply with quote

I see the post, but it not work

I have change the code now
after each glcd_sendcmd i have inserted a delay

glcd_sendCMD(GLCD_CMD_DISPLAY_WRITE);
delay_us(200);

Now when i use this command
glcd_fillScreenText('A') than the screen will fill with 'A'
The only thing now is that the last 3 lines not filled with "a", only garbage
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Nov 18, 2007 1:00 pm     Reply with quote

Some days further and have little success.
I use the code below and can get text on the lcd

Code:
#include <18F4620.h>
#use delay(clock=20000000)
#fuses HS,NOWDT,NOBROWNOUT,NOPUT,NOLVP,DEBUG,NOSTVREN,NOPROTECT

#include <s1d13305.h>
#include <graphics.h>

void main() {
   int16 i;
   
   output_high(GLCD_RST);
   output_high(GLCD_CS);
   output_high(GLCD_RD);
   output_high(GLCD_WR);
   delay_us(200);
   

   glcd_sendCMD(GLCD_CMD_SYSTEM);
   delay_us(200);
   TGLCD_DATA
   glcd_sendByte(0x30);   // 00h    00110000 (0x30)   IV & Single Panel
   glcd_sendByte(0x87);   // 01h    10000111 (0x87)   Horizontal Character size & (MOD=1)
   glcd_sendByte(0x07);   // 02h    00000111 (0x07)   Vertical Character size
   glcd_sendByte(0x27);   // 03h    00100111 (0x27)   C/R   Characters/Row - 1
   glcd_sendByte(0x2A);   // 04h    00101010 (0x2A)   TC/R  Total Character bytes / Row
   glcd_sendByte(0xEF);   // 05h    11101111 (0xEF)   L/F   Frame height in lines - 1
   glcd_sendByte(0x28);   // 06h    00011100 (0x28)   Horizontal Address Range 0
   glcd_sendByte(0x00);   // 07h    00000000 (0x00)   Horizontal Address Range 1
   
   glcd_sendCMD(GLCD_CMD_SCROLL);
   delay_us(200);
   TGLCD_DATA
   glcd_sendByte(0x00);  // 0Bh    0x00              Scn Blk 1 StrtAdr L     [TEXT AREA]
   glcd_sendByte(0x00);  // 0Ch    0x00              Scn Blk 1 StrtAdr H     [0x0000]
   glcd_sendByte(0xF1);  // 0Dh    0xF1              Scn Blk 1 Size
   glcd_sendByte(0x00);  // 0Eh    0x00              Scn Blk 2 StrtAdr L     [GRFX AREA]
   glcd_sendByte(0x10);  // 0Fh    0x10              Scn Blk 2 StrtAdr H     [0x1000]
   glcd_sendByte(0xF1);  // 10h    0xF1              Scn Blk 2 Size
   glcd_sendByte(0x00);  // 11h    0                 Scn Blk 3 StrtAdr L
   glcd_sendByte(0x00);  // 12h    0                 Scn Blk 3 StrtAdr H
   glcd_sendByte(0x00);  // 13h    0                 Scn Blk 4 StrtAdr L
   glcd_sendByte(0x00);  // 14h    0                 Scn Blk 4 StrtAdr H
   
   glcd_sendCMD(GLCD_CMD_CSR_FORM);
   delay_us(200);
   TGLCD_DATA
   glcd_sendByte(0x07);  // 15h   7                  Curs Width
   glcd_sendByte(0x07);  // 16h   7                  Curs Height     b7=CM 0=underscore curs
   
   glcd_sendCMD(GLCD_CMD_CSRDIR_RIGHT);
   delay_us(200);
   TGLCD_DATA
   
   glcd_sendCMD(GLCD_CMD_OVERLAY);
   delay_us(200);
   TGLCD_DATA
   glcd_sendByte(0x01);  // 18h   0x01               2L / blk3-1 = txt / (L1 EXOR L2) OR L3
   
   glcd_sendCMD(GLCD_CMD_HDOT_SCR);
   delay_us(200);
   TGLCD_DATA
   glcd_sendByte(0x00);  // 1Bh                      Horizontal Scroll Rate = 1
   
   glcd_sendCMD(GLCD_CMD_SET_CSR_ADDR);
   delay_us(200);
   TGLCD_DATA
   glcd_sendByte(0x00);  // 1Ch                      Set Cursor Addr 0x0000
   glcd_sendByte(0x00);  // 1Dh
   
   glcd_sendCMD(GLCD_CMD_DISPLAY_WRITE);
   delay_us(200);
   TGLCD_DATA
   for(i=0;i<1200;i++)
      glcd_sendByte(0x20);
   
   glcd_sendCMD(GLCD_CMD_SET_CSR_ADDR);
   delay_us(200);
   TGLCD_DATA
   glcd_sendByte(0x00);  // 1Ch                      Set Cursor Addr 0x1000
   glcd_sendByte(0x10);  // 1Dh
   
   glcd_sendCMD(GLCD_CMD_DISPLAY_WRITE);
   delay_us(200);
   TGLCD_DATA
   for(i=0;i<9600;i++)
      glcd_sendByte(0x00);
      
   glcd_sendCMD(GLCD_CMD_DISP_ON);
   delay_us(200);
   TGLCD_DATA
   glcd_sendByte(0x16); // A0h  00010110 (0x16)      SAD2:1 ON / No Flashing   & Curs Flash
   
   glcd_sendCMD(GLCD_CMD_SET_CSR_ADDR);
   delay_us(200);
   TGLCD_DATA
   glcd_sendByte(0x00); // 1Ch                  Set Cursor Addr 0x0000
   glcd_sendByte(0x00); // 1Dh
   
   glcd_sendCMD(GLCD_CMD_DISPLAY_WRITE);   
   delay_us(200);
   TGLCD_DATA
   glcd_sendByte('t');
   glcd_sendByte('e');
   glcd_sendByte('s');
   glcd_sendByte('t');
   



But when i use the graphics.h library than i get garbage on the lcd

char strg[]="TEST";
glcd_text57(50,50,strg,1,ON);

Did not work the CCS library or what is wrong
Hope i can get some help[/code]
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Nov 18, 2007 1:49 pm     Reply with quote

Quote:
Now when i use this command glcd_fillScreenText('A') than the screen
will fill with 'A' The only thing now is that the last 3 lines not filled
with "a", only garbage.

Quote:
Some days further and have little success.
I use the code below and can get text on the lcd.


Do you still have the problem where the last 3 lines are filled with garbage ?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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