Picproje Elektronik Sitesi

DERLEYİCİLER => CCS C => Konuyu başlatan: serkanpk - 23 Kasım 2010, 00:20:51

Başlık: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: serkanpk - 23 Kasım 2010, 00:20:51
Nette bir iki araştırma sonucu sed1335.c kaynak kodunun RA8835 le aynı olduğunu gördüm. Ve denemeye karar verdim.
Ancak PIC C deki kütüphanede graphics.c dosyasındaki bazı fonksiyonlar ekranda hatalı çalışıyor.
Yalnız dikkatimi çeken konu RA8835.c içindeki text fonksiyonu doğru çalışıyor.

RA8835.c

#define GLCD_RST PIN_C0
#define GLCD_RD PIN_C4
#define GLCD_WR PIN_C3
#define GLCD_CS PIN_C1
#define GLCD_A0 PIN_C2

#DEFINE GLCD_DB0 PIN_D0
#DEFINE GLCD_DB1 PIN_D1
#DEFINE GLCD_DB2 PIN_D2
#DEFINE GLCD_DB3 PIN_D3
#DEFINE GLCD_DB4 PIN_D4
#DEFINE GLCD_DB5 PIN_D5
#DEFINE GLCD_DB6 PIN_D6
#DEFINE GLCD_DB7 PIN_D7

#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 COMMAND_MODE   output_high(GLCD_A0);
#define DATA_MODE       output_low(GLCD_A0);

#DEFINE RA8835_GRAPHICSTART 0x2580

void GlcdPutData(INT8 data);
int8 TakeData(void);
void GLCD_WriteCommand(int8 commandToWrite);
void GLCD_WriteData(int8 dataToWrite);
int8 GLCD_ReadData(void);
void setCursorAddress(int16 addr);
void GlcdGotoTextXY(int16 x, int16 y);
void GlcdPutC(char c);
void FillText(char cara);
void FillGraphic(int1 parameter);
void glcd_RAinit(void);
int8 GLCD_ReadStatus(void);

void GlcdPutData(int8 data)
   {
   output_bit(GLCD_DB0, bit_test(data,0));     
   output_bit(GLCD_DB1, bit_test(data,1));                   
   output_bit(GLCD_DB2, bit_test(data,2));                   
   output_bit(GLCD_DB3, bit_test(data,3));
   output_bit(GLCD_DB4, bit_test(data,4));
   output_bit(GLCD_DB5, bit_test(data,5));                   
   output_bit(GLCD_DB6, bit_test(data,6));                 
   output_bit(GLCD_DB7, bit_test(data,7));
   }
   

   
int8 TakeData(VOID)
   {
   INT8 data = 0;
   data += input (GLCD_DB0);
   data += input (GLCD_DB1) * 2;
   data += input (GLCD_DB2) * 4;
   data += input (GLCD_DB3) * 8;
   data += input (GLCD_DB4) * 16;
   data += input (GLCD_DB5) * 32;
   data += input (GLCD_DB6) * 64;
   data += input (GLCD_DB7) * 128;
   RETURN data;
   }

void GLCD_WriteCommand(int8 commandToWrite)
{
GlcdPutData(commandToWrite);

COMMAND_MODE

output_low(GLCD_WR);
output_low(GLCD_CS);

delay_cycles(1);

output_high(GLCD_WR);
output_high(GLCD_CS);
}

void GLCD_WriteData(int8 dataToWrite)
{
GlcdPutData(dataToWrite);

DATA_MODE

output_low(GLCD_WR);
output_low(GLCD_CS);

delay_cycles(1);

output_high(GLCD_WR);
output_high(GLCD_CS);
}

int8 GLCD_ReadData(void)
{
int8 tmp;

output_low(GLCD_RD);
output_low(GLCD_CS);
delay_cycles(4);
tmp = TakeData();
output_high(GLCD_RD);
output_high(GLCD_CS);

return tmp;
}

void glcd_RAinit(void)
{
 
   output_high(GLCD_RST);
   output_high(GLCD_CS);
   output_high(GLCD_RD);
   output_high(GLCD_WR);
   
   //system set
   GLCD_WriteCommand(0x40);
   GLCD_WriteData(0x30);
   GLCD_WriteData(0x87);
   GLCD_WriteData(0x07);
   GLCD_WriteData(0x27);
   GLCD_WriteData(0x2F);
   GLCD_WriteData(0xEF);
   GLCD_WriteData(0x28);
   GLCD_WriteData(0x00);
   
   //scroll
   GLCD_WriteCommand(0x44);
   GLCD_WriteData(0x00);
   GLCD_WriteData(0x00);
   GLCD_WriteData(0xF0);
   GLCD_WriteData(0x80);
   GLCD_WriteData(0x25);
   GLCD_WriteData(0xF0);
   GLCD_WriteData(0x00);
   GLCD_WriteData(0x4B);
   GLCD_WriteData(0x00);
   GLCD_WriteData(0x00);
   //HDOT SCR
   
   GLCD_WriteCommand(0x5A);
   GLCD_WriteData(0x00);
   
   //OVLAY
   GLCD_WriteCommand(0x5B);
   GLCD_WriteData(0x01);
   
   //erase all screen
   FillGraphic(OFF);
   FillText(' ');
   
   //DISP ON
   GLCD_WriteCommand(0x58);
   GLCD_WriteData(0x56);
   
   //CSRFORM
   GLCD_WriteCommand(0x5D);
   GLCD_WriteData(0x04);   
   GLCD_WriteData(0x86);
   
   //DISP ON
   GLCD_WriteCommand(0x59);
   
   //CSDIR
   GLCD_WriteCommand(0x4C);
   
   //CSRW
   setCursorAddress(0x0000);
}


void FillGraphic(int1 parameter)
   {
   long count;
   //set cursor to 2580h
   setCursorAddress(0x2580);
   //put 00h in all graphic space
   count = 9600;
   GLCD_WriteCommand(0x42);
   while(count != 0)
      {
       GLCD_WriteData(0xFF * parameter);
      count--;
      }
   }
   
void FillText(char cara)
   {
   long count;
   //set cursor to 0000h
   setCursorAddress(0x0000);
   //put 00h in all text space
   count = 1200;
   GLCD_WriteCommand(0x42);
   while(count != 0)
      {
       GLCD_WriteData(cara);
      count--;
      }
   }
   
void GlcdPutC(char c)
   {
   GLCD_WriteCommand(0x42);
   GLCD_WriteData(c);
   }
   
//x and y : 1 to max   
void GlcdGotoTextXY(int16 x, int16 y)
   {
   int16 adress = 0;
   adress = (y-1)*40;
   adress = adress+ x-1;
   setCursorAddress(adress);
   }
   
void setCursorAddress(int16 addr)
{
   int8 adress;
   GLCD_WriteCommand(0x46);
   adress = addr & 0xFF;
   GLCD_WriteData(adress);
   adress = addr >> 8;
   GLCD_WriteData(adress);
}

void GLCD_Pixel(int16 x,int16 y, int1 color)
{
int8 tmp = 0;
int16 address = 0;

address = RA8835_GRAPHICSTART + (40 * y) + (x/8);
setCursorAddress(address);

GLCD_WriteCommand(0x43);
tmp = GLCD_ReadData();

if(color == ON)
  tmp |= (1 << (7 - (x % 8)));
else
  tmp &= ~(1 << (7 - (x % 8)));

setCursorAddress(address);
GLCD_WriteCommand(0x42);
GLCD_WriteData(tmp);
}

void GLCD_GraphicGoTo(int16 x,int16 y)
{
setCursorAddress(RA8835_GRAPHICSTART + (y * 40) + x/8);
}

int8 GLCD_ReadStatus(void)
{
int8 tmp;

output_low(GLCD_RD);
output_low(GLCD_CS);
output_low(GLCD_A0);
delay_cycles(1);
tmp = takedata();
output_high(GLCD_RD);
output_high(GLCD_CS);
output_high(GLCD_A0);

return tmp;
}


graphics.c

/////////////////////////////////////////////////////////////////////////
////                          graphics.c                             ////
////                                                                 ////
////   This file contains functions to draw lines, rectangles, bars, ////
////   circles and text to a display. A function which draws a       ////
////   single pixel must be defined before calling the functions in  ////
////   this file. Call it glcd_pixel(x, y, color) where x is the     ////
////   horizontal coordinate, y is the vertical coordinate, and      ////
////   color is 1 bit to turn the pixel on or off.                   ////
////                                                                 ////
////   * Note: (0, 0) is treated as the upper left corner            ////
////                                                                 ////
/////////////////////////////////////////////////////////////////////////
////                                                                 ////
////  glcd_line(x1, y1, x2, y2, color)                               ////
////     * Draws a line from the first point to the second point     ////
////       with the given color                                      ////
////       - color can be ON or OFF                                  ////
////                                                                 ////
////  glcd_rect(x1, y1, x2, y2, fill, color)                         ////
////     * Draws a rectangle with one corner at point (x1,y1) and    ////
////       the other corner at point (x2,y2)                         ////
////       - fill can be YES or NO                                   ////
////       - color can be ON or OFF                                  ////
////                                                                 ////
////  glcd_bar(x1, y1, x2, y2, width, color)                         ////
////     * Draws a bar (wide line) from the first point to the       ////
////       second point                                              ////
////       - width is the number of pixels wide                      ////
////       - color is ON or OFF                                      ////
////                                                                 ////
////  glcd_circle(x, y, radius, fill, color)                         ////
////     * Draws a circle with center at (x,y)                       ////
////       - fill can be YES or NO                                   ////
////       - color can be ON or OFF                                  ////
////                                                                 ////
////  glcd_text57(x, y, textptr, size, color)                        ////
////     * Write the null terminated text pointed to by textptr with ////
////       the upper left coordinate of the first character at (x,y) ////
////       Characters are 5 pixels wide and 7 pixels tall            ////
////       - size is an integer that scales the size of the text     ////
////       - color is ON or OFF                                      ////
////     * Note - This function wraps characters to the next line    ////
////              use #define GLCD_WIDTH to specify a display width  ////
////                                                                 ////
/////////////////////////////////////////////////////////////////////////
////        (C) Copyright 1996, 2004 Custom Computer Services        ////
//// This source code may only be used by licensed users of the CCS  ////
//// C compiler.  This source code may only be distributed to other  ////
//// licensed users of the CCS C compiler.  No other use,            ////
//// reproduction or distribution is permitted without written       ////
//// permission.  Derivative programs created using this software    ////
//// in object code form are not restricted in any way.              ////
/////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////
#ifndef GRAPHICS_DRAWING_FUNCTIONS
#define GRAPHICS_DRAWING_FUNCTIONS
/////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////
#ifndef ON
#define ON  1
#endif

#ifndef OFF
#define OFF 0
#endif

#ifndef YES
#define YES 1
#endif

#ifndef NO
#define NO  0
#endif
/////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////
//// Defines a 5x7 font
/////////////////////////////////////////////////////////////////////////
const int8 FONT[51][5] ={0x00, 0x00, 0x00, 0x00, 0x00, // SPACE
                         0x00, 0x00, 0x5F, 0x00, 0x00, // !
                         0x00, 0x03, 0x00, 0x03, 0x00, // "
                         0x14, 0x3E, 0x14, 0x3E, 0x14, // #
                         0x24, 0x2A, 0x7F, 0x2A, 0x12, // $
                         0x43, 0x33, 0x08, 0x66, 0x61, // %
                         0x36, 0x49, 0x55, 0x22, 0x50, // &
                         0x00, 0x05, 0x03, 0x00, 0x00, // '
                         0x00, 0x1C, 0x22, 0x41, 0x00, // (
                         0x00, 0x41, 0x22, 0x1C, 0x00, // )
                         0x14, 0x08, 0x3E, 0x08, 0x14, // *
                         0x08, 0x08, 0x3E, 0x08, 0x08, // +
                         0x00, 0x50, 0x30, 0x00, 0x00, // ,
                         0x08, 0x08, 0x08, 0x08, 0x08, // -
                         0x00, 0x60, 0x60, 0x00, 0x00, // .
                         0x20, 0x10, 0x08, 0x04, 0x02, // /
                         0x3E, 0x51, 0x49, 0x45, 0x3E, // 0
                         0x00, 0x04, 0x02, 0x7F, 0x00, // 1
                         0x42, 0x61, 0x51, 0x49, 0x46, // 2
                         0x22, 0x41, 0x49, 0x49, 0x36, // 3
                         0x18, 0x14, 0x12, 0x7F, 0x10, // 4
                         0x27, 0x45, 0x45, 0x45, 0x39, // 5
                         0x3E, 0x49, 0x49, 0x49, 0x32, // 6
                         0x01, 0x01, 0x71, 0x09, 0x07, // 7
                         0x36, 0x49, 0x49, 0x49, 0x36, // 8
                         0x26, 0x49, 0x49, 0x49, 0x3E, // 9
                         0x00, 0x36, 0x36, 0x00, 0x00, // :
                         0x00, 0x56, 0x36, 0x00, 0x00, // ;
                         0x08, 0x14, 0x22, 0x41, 0x00, // <
                         0x14, 0x14, 0x14, 0x14, 0x14, // =
                         0x00, 0x41, 0x22, 0x14, 0x08, // >
                         0x02, 0x01, 0x51, 0x09, 0x06, // ?
                         0x3E, 0x41, 0x59, 0x55, 0x5E, // @
                         0x7E, 0x09, 0x09, 0x09, 0x7E, // A
                         0x7F, 0x49, 0x49, 0x49, 0x36, // B
                         0x3E, 0x41, 0x41, 0x41, 0x22, // C
                         0x7F, 0x41, 0x41, 0x41, 0x3E, // D
                         0x7F, 0x49, 0x49, 0x49, 0x41, // E
                         0x7F, 0x09, 0x09, 0x09, 0x01, // F
                         0x3E, 0x41, 0x41, 0x49, 0x3A, // G
                         0x7F, 0x08, 0x08, 0x08, 0x7F, // H
                         0x00, 0x41, 0x7F, 0x41, 0x00, // I
                         0x30, 0x40, 0x40, 0x40, 0x3F, // J
                         0x7F, 0x08, 0x14, 0x22, 0x41, // K
                         0x7F, 0x40, 0x40, 0x40, 0x40, // L
                         0x7F, 0x02, 0x0C, 0x02, 0x7F, // M
                         0x7F, 0x02, 0x04, 0x08, 0x7F, // N
                         0x3E, 0x41, 0x41, 0x41, 0x3E, // O
                         0x7F, 0x09, 0x09, 0x09, 0x06, // P
                         0x1E, 0x21, 0x21, 0x21, 0x5E, // Q
                         0x7F, 0x09, 0x09, 0x09, 0x76};// R

const int8 FONT2[44][5]={0x26, 0x49, 0x49, 0x49, 0x32, // S
                         0x01, 0x01, 0x7F, 0x01, 0x01, // T
                         0x3F, 0x40, 0x40, 0x40, 0x3F, // U
                         0x1F, 0x20, 0x40, 0x20, 0x1F, // V
                         0x7F, 0x20, 0x10, 0x20, 0x7F, // W
                         0x41, 0x22, 0x1C, 0x22, 0x41, // X
                         0x07, 0x08, 0x70, 0x08, 0x07, // Y
                         0x61, 0x51, 0x49, 0x45, 0x43, // Z
                         0x00, 0x7F, 0x41, 0x00, 0x00, // [
                         0x02, 0x04, 0x08, 0x10, 0x20, // \
                         0x00, 0x00, 0x41, 0x7F, 0x00, // ]
                         0x04, 0x02, 0x01, 0x02, 0x04, // ^
                         0x40, 0x40, 0x40, 0x40, 0x40, // _
                         0x00, 0x01, 0x02, 0x04, 0x00, // `
                         0x20, 0x54, 0x54, 0x54, 0x78, // a
                         0x7F, 0x44, 0x44, 0x44, 0x38, // b
                         0x38, 0x44, 0x44, 0x44, 0x44, // c
                         0x38, 0x44, 0x44, 0x44, 0x7F, // d
                         0x38, 0x54, 0x54, 0x54, 0x18, // e
                         0x04, 0x04, 0x7E, 0x05, 0x05, // f
                         0x08, 0x54, 0x54, 0x54, 0x3C, // g
                         0x7F, 0x08, 0x04, 0x04, 0x78, // h
                         0x00, 0x44, 0x7D, 0x40, 0x00, // i
                         0x20, 0x40, 0x44, 0x3D, 0x00, // j
                         0x7F, 0x10, 0x28, 0x44, 0x00, // k
                         0x00, 0x41, 0x7F, 0x40, 0x00, // l
                         0x7C, 0x04, 0x78, 0x04, 0x78, // m
                         0x7C, 0x08, 0x04, 0x04, 0x78, // n
                         0x38, 0x44, 0x44, 0x44, 0x38, // o
                         0x7C, 0x14, 0x14, 0x14, 0x08, // p
                         0x08, 0x14, 0x14, 0x14, 0x7C, // q
                         0x00, 0x7C, 0x08, 0x04, 0x04, // r
                         0x48, 0x54, 0x54, 0x54, 0x20, // s
                         0x04, 0x04, 0x3F, 0x44, 0x44, // t
                         0x3C, 0x40, 0x40, 0x20, 0x7C, // u
                         0x1C, 0x20, 0x40, 0x20, 0x1C, // v
                         0x3C, 0x40, 0x30, 0x40, 0x3C, // w
                         0x44, 0x28, 0x10, 0x28, 0x44, // x
                         0x0C, 0x50, 0x50, 0x50, 0x3C, // y
                         0x44, 0x64, 0x54, 0x4C, 0x44, // z
                         0x00, 0x08, 0x36, 0x41, 0x41, // {
                         0x00, 0x00, 0x7F, 0x00, 0x00, // |
                         0x41, 0x41, 0x36, 0x08, 0x00, // }
                         0x02, 0x01, 0x02, 0x04, 0x02};// ~
/////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////
// Purpose:       Draw a line on a graphic LCD using Bresenham's
//                line drawing algorithm
// Inputs:        (x1, y1) - the start coordinate
//                (x2, y2) - the end coordinate
//                color - ON or OFF
// Dependencies:  glcd_pixel()
/////////////////////////////////////////////////////////////////////////
#ifdef LARGE_LCD
void glcd_line(int16 x1, int16 y1, int16 x2, int16 y2, int1 color)
#else
void glcd_line(int8 x1, int8 y1, int8 x2, int8 y2, int1 color)
#endif
{
   int16        dy, dx;
   signed int8  addx=1, addy=1;
   signed int16 P, diff;

   #ifdef LARGE_LCD
   int16 i=0;
   dx = abs((signed int16)(x2 - x1));
   dy = abs((signed int16)(y2 - y1));
   #else
   int8 i=0;
   dx = abs((signed int8)(x2 - x1));
   dy = abs((signed int8)(y2 - y1));
   #endif

   if(x1 > x2)
      addx = -1;
   if(y1 > y2)
      addy = -1;

   if(dx >= dy)
   {
      dy *= 2;
      P = dy - dx;
      diff = P - dx;

      for(; i<=dx; ++i)
      {
         glcd_pixel(x1, y1, color);

         if(P < 0)
         {
            P  += dy;
            x1 += addx;
         }
         else
         {
            P  += diff;
            x1 += addx;
            y1 += addy;
         }
      }
   }
   else
   {
      dx *= 2;
      P = dx - dy;
      diff = P - dy;

      for(; i<=dy; ++i)
      {
         glcd_pixel(x1, y1, color);

         if(P < 0)
         {
            P  += dx;
            y1 += addy;
         }
         else
         {
            P  += diff;
            x1 += addx;
            y1 += addy;
         }
      }
   }
}
/////////////////////////////////////////////////////////////////////////
// Purpose:       Draw a rectangle on a graphic LCD
// Inputs:        (x1, y1) - the start coordinate
//                (x2, y2) - the end coordinate
//                fill  - YES or NO
//                color - ON or OFF
// Dependencies:  glcd_pixel(), glcd_line()
/////////////////////////////////////////////////////////////////////////
#ifdef LARGE_LCD
void glcd_rect(int16 x1, int16 y1, int16 x2, int16 y2, int1 fill, int1 color)
#else
void glcd_rect(int8 x1, int8 y1, int8 x2, int8 y2, int1 fill, int1 color)
#endif
{
   if(fill)
   {
      #ifdef LARGE_LCD
      int16 i, xmin, xmax, ymin, ymax;
      #else
      int8  i, xmin, xmax, ymin, ymax;
      #endif

      if(x1 < x2)                            //  Find x min and max
      {
         xmin = x1;
         xmax = x2;
      }
      else
      {
         xmin = x2;
         xmax = x1;
      }

      if(y1 < y2)                            // Find the y min and max
      {
         ymin = y1;
         ymax = y2;
      }
      else
      {
         ymin = y2;
         ymax = y1;
      }

      for(; xmin <= xmax; ++xmin)
      {
         for(i=ymin; i<=ymax; ++i)
         {
            glcd_pixel(xmin, i, color);
         }
      }
   }
   else
   {
      glcd_line(x1, y1, x2, y1, color);      // Draw the 4 sides
      glcd_line(x1, y2, x2, y2, color);
      glcd_line(x1, y1, x1, y2, color);
      glcd_line(x2, y1, x2, y2, color);
   }
}

/////////////////////////////////////////////////////////////////////////
// Purpose:       Draw a bar (wide line) on a graphic LCD
// Inputs:        (x1, y1) - the start coordinate
//                (x2, y2) - the end coordinate
//                width  - The number of pixels wide
//                color - ON or OFF
/////////////////////////////////////////////////////////////////////////
#ifdef LARGE_LCD
void glcd_bar(int16 x1, int16 y1, int16 x2, int16 y2, int8 width, int1 color)
#else
void glcd_bar(int8 x1, int8 y1, int8 x2, int8 y2, int8 width, int1 color)
#endif
{
   int8         half_width;
   signed int16 dy, dx;
   signed int8  addx=1, addy=1, j;
   signed int16 P, diff, c1, c2;

   #ifdef LARGE_LCD
   int16 i=0;
   dx = abs((signed int16)(x2 - x1));
   dy = abs((signed int16)(y2 - y1));
   #else
   int8 i=0;
   dx = abs((signed int8)(x2 - x1));
   dy = abs((signed int8)(y2 - y1));
   #endif
   half_width = width/2;
   c1 = -(dx*x1 + dy*y1);
   c2 = -(dx*x2 + dy*y2);

   if(x1 > x2)
   {
      signed int16 temp;
      temp = c1;
      c1 = c2;
      c2 = temp;
      addx = -1;
   }
   if(y1 > y2)
   {
      signed int16 temp;
      temp = c1;
      c1 = c2;
      c2 = temp;
      addy = -1;
   }

   if(dx >= dy)
   {
      P = 2*dy - dx;
      diff = P - dx;

      for(i=0; i<=dx; ++i)
      {
         for(j=-half_width; j<half_width+width%2; ++j)
         {
            #ifdef LARGE_LCD
            int16 temp;
            #else
            int8 temp;
            #endif

            temp = dx*x1+dy*(y1+j);    // Use more RAM to increase speed
            if(temp+c1 >= 0 && temp+c2 <=0)
               glcd_pixel(x1, y1+j, color);
         }
         if(P < 0)
         {
            P  += 2*dy;
            x1 += addx;
         }
         else
         {
            P  += diff;
            x1 += addx;
            y1 += addy;
         }
      }
   }
   else
   {
      P = 2*dx - dy;
      diff = P - dy;

      for(i=0; i<=dy; ++i)
      {
         if(P < 0)
         {
            P  += 2*dx;
            y1 += addy;
         }
         else
         {
            P  += diff;
            x1 += addx;
            y1 += addy;
         }
         for(j=-half_width; j<half_width+width%2; ++j)
         {
            #ifdef LARGE_LCD
            int16 temp;
            #else
            int8 temp;
            #endif

            temp = dx*x1+dy*(y1+j);    // Use more RAM to increase speed
            if(temp+c1 >= 0 && temp+c2 <=0)
               glcd_pixel(x1+j, y1, color);
         }
      }
   }
}


/////////////////////////////////////////////////////////////////////////
// Purpose:       Draw a circle on a graphic LCD
// Inputs:        (x,y) - the center of the circle
//                radius - the radius of the circle
//                fill - YES or NO
//                color - ON or OFF
/////////////////////////////////////////////////////////////////////////
#ifdef LARGE_LCD
void glcd_circle(int16 x, int16 y, int16 radius, int1 fill, int1 color)
#else
void glcd_circle(int8 x, int8 y, int8 radius, int1 fill, int1 color)
#endif
{
   #ifdef LARGE_LCD
   signed int16 a, b, P;
   #else
   signed int8  a, b, P;
   #endif

   a = 0;
   b = radius;
   P = 1 - radius;

   do
   {
      if(fill)
      {
         glcd_line(x-a, y+b, x+a, y+b, color);
         glcd_line(x-a, y-b, x+a, y-b, color);
         glcd_line(x-b, y+a, x+b, y+a, color);
         glcd_line(x-b, y-a, x+b, y-a, color);
      }
      else
      {
         glcd_pixel(a+x, b+y, color);
         glcd_pixel(b+x, a+y, color);
         glcd_pixel(x-a, b+y, color);
         glcd_pixel(x-b, a+y, color);
         glcd_pixel(b+x, y-a, color);
         glcd_pixel(a+x, y-b, color);
         glcd_pixel(x-a, y-b, color);
         glcd_pixel(x-b, y-a, color);
      }

      if(P < 0)
         P += 3 + 2 * a++;
      else
         P += 5 + 2 * (a++ - b--);
    } while(a <= b);
}


/////////////////////////////////////////////////////////////////////////
// Purpose:       Write text on a graphic LCD
// Inputs:        (x,y) - The upper left coordinate of the first letter
//                textptr - A pointer to an array of text to display
//                size - The size of the text: 1 = 5x7, 2 = 10x14, ...
//                color - ON or OFF
/////////////////////////////////////////////////////////////////////////
#ifdef LARGE_LCD
void glcd_text57(int16 x, int16 y, char* textptr, int8 size, int1 color)
#else
void glcd_text57(int8 x, int8 y, char* textptr, int8 size, int1 color)
#endif
{
   int8 j, k, l, m;                       // Loop counters
   int8 pixelData[5];                     // Stores character data

   for(; *textptr != '\0'; ++textptr, ++x)// Loop through the passed string
   {
      if(*textptr < 'S') // Checks if the letter is in the first font array
         memcpy(pixelData, FONT[*textptr - ' '], 5);
      else if(*textptr <= '~') // Check if the letter is in the second font array
         memcpy(pixelData, FONT2[*textptr - 'S'], 5);
      else
         memcpy(pixelData, FONT[0], 5);   // Default to space

      // Handles newline and carriage returns
      switch(*textptr)
      {
         case '\n':
            y += 7*size + 1;
            continue;
         case '\r':
            x = 0;
            continue;
      }

      if(x+5*size >= GLCD_WIDTH)          // Performs character wrapping
      {
         x = 0;                           // Set x at far left position
         y += 7*size + 1;                 // Set y at next position down
      }
      for(j=0; j<5; ++j, x+=size)         // Loop through character byte data
      {
         for(k=0; k < 7; ++k)             // Loop through the vertical pixels
         {
            if(bit_test(pixelData[j], k)) // Check if the pixel should be set
            {
               for(l=0; l < size; ++l)    // These two loops change the
               {                          // character's size
                  for(m=0; m < size; ++m)
                  {
                     glcd_pixel(x+m, y+k*size+l, color); // Draws the pixel
                  }
               }
            }
         }
      }
   }
}

#endif






Main

#include <18F4620.h>
#use delay(clock=4000000)
#fuses HS,NOWDT,PROTECT,NOLVP,NOBROWNOUT, PUT
#define LARGE_LCD 1
#include <RA8835V2.c>
#include <MYGRAPHICS.c>

char t_menu[]          ="MENU";

void main()
   {
output_high(PIN_C5);//burdaRA init fonksiyonundaki gecikmeyi görmek istedim yaklaşık 2 saniye
glcd_RAinit();
output_low(PIN_C5);
delay_ms(100);

GlcdGotoTextXY(1,1);
printf(GlcdPutC,"MARMARA UNIVERSITESI");

GlcdGotoTextXY(1,2);
printf(GlcdPutC,"ELEKTRONIK HABERLESME");
GlcdGotoTextXY(1,3);
printf(GlcdPutC,"DENEME");
//graghics.c nin içindeki fonksiyonlar
glcd_text57(15, 50, t_menu, 2, 1);
glcd_circle(250,180,30,0,1);
glcd_rect(200,1,300,80,1,1);
//
     for(;;) // aşağıdaki kısmı sadece işlmecinin doğru çalışıp çalışmadını anlamak için ekledim
   {
output_high(PIN_C5);
delay_ms( 100 );
output_low(PIN_C5);
delay_ms( 100);

     
  }

   }



Ekran görüntüleri aşağıda mevcut. Bu durum hakkında yardımcı olabilecek var mı ?
(http://[url=http://img227.imageshack.us/i/22112010283.jpg/%5D%5BIMG%5Dhttp://img227.imageshack.us/img227/3424/22112010283.th.jpg)[/URL]
[IMG]http://img593.imageshack.us/img593/9630/23112010290.th.jpg[/img] (http://img593.imageshack.us/i/23112010290.jpg/)
[/img]



Yazılım sürümü PIC C 4.110
[IMG]http://img593.imageshack.us/img593/9630/23112010290.th.jpg[/img] (http://img593.imageshack.us/i/23112010290.jpg/)


Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: justice_for_all - 23 Kasım 2010, 00:35:51
Alıntı yapılan: serkanpk - 23 Kasım 2010, 00:20:51
RA8835.c içindeki text fonksiyonu doğru çalışıyor.

Hangi text fonksiyonundan bahsediyosunuz acaba??
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: ahmet2004 - 23 Kasım 2010, 02:12:56
Bir adet 18f452  buldum kodları ona yükledim Lcd düzgün çalışıyor bir sorun çıkmadı.

(http://img364.yukle.tc/images/2299IMG_0583k_resize.JPG)
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: celebrium - 23 Kasım 2010, 20:01:47
Ahmet hocam saygılar Senin LCD nin çipseti nedir SED1335 mi?
Birdeki yukardaki durum la ilgili LCD bozuk olabilir mi?
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: ahmet2004 - 23 Kasım 2010, 21:06:04
Lcd sed1335 çipsetli.Ama nasıl bağlantı yapılıyor nereye bağlanıyor uçlar bilmiyoruz.

O yüzden pek yorum yapamıyorum herşey olabilir demekle yetiniyorum sadece.
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: serkanpk - 23 Kasım 2010, 23:37:26
Donanımsal kaynaklı bir sıkıntıdan olabilir mi?
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: ahmet2004 - 23 Kasım 2010, 23:56:21
Mesela breadboard sorunlu olabilir.Kontakları doğru düzgün bile değmiyor fazla açık olabiliyor.

En sağlam pcb yapılmalı düzgün lehimlenmeli.

Ucuz breadboardlar teneke kontaklı bir kablo taktıktan sonra genişliyor yani çok uyduruk.
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: celebrium - 24 Kasım 2010, 00:00:36
Bence bu çipset in uyumsuzluğu bağlantılar aşağıdaki gibi aynı sorunu CCS C Forumda Murtis diye biriside yaşamış.
http://www.ccsinfo.com/forum/viewtopic.php?t=34970&highlight=ra8835



Bağlantılar yazılıma göre böyle 
kontrol portları
#define GLCD_RST PIN_C0
#define GLCD_RD PIN_C4
#define GLCD_WR PIN_C3
#define GLCD_CS PIN_C1
#define GLCD_A0 PIN_C2
data portları
#DEFINE GLCD_DB0 PIN_D0
#DEFINE GLCD_DB1 PIN_D1
#DEFINE GLCD_DB2 PIN_D2
#DEFINE GLCD_DB3 PIN_D3
#DEFINE GLCD_DB4 PIN_D4
#DEFINE GLCD_DB5 PIN_D5
#DEFINE GLCD_DB6 PIN_D6
#DEFINE GLCD_DB7 PIN_D7
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: serkanpk - 24 Kasım 2010, 00:04:13
Devre pcb halinde.
Çalışma frekansı mesela 4-8-20MHZ denedim ama sonuç aynı.
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: cdurakbasi - 24 Kasım 2010, 21:44:40
Alıntı yapılan: serkanpk - 24 Kasım 2010, 00:04:13
Devre pcb halinde.
Çalışma frekansı mesela 4-8-20MHZ denedim ama sonuç aynı.

modülünüzdeki chipin sel1 pininin lojik seviyesinin seçtiği komut setinin kodunuzunki ile aynı olduğundan emin olun (6800 veya 8080)
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: serkanpk - 26 Kasım 2010, 12:44:06
Alıntı yapılan: justice_for_all - 23 Kasım 2010, 00:35:51
Alıntı yapılan: serkanpk - 23 Kasım 2010, 00:20:51
RA8835.c içindeki text fonksiyonu doğru çalışıyor.

Hangi text fonksiyonundan bahsediyosunuz acaba??
justice_for_all , aşağıdaki komut düzgün çalışıyor.

GlcdGotoTextXY(1,1);
printf(GlcdPutC,"MARMARA UNIVERSITESI");

GlcdGotoTextXY(1,2);
printf(GlcdPutC,"ELEKTRONIK HABERLESME");
GlcdGotoTextXY(1,3);
printf(GlcdPutC,"DENEME");

ancak grafik komutları çalışmıyor.

glcd_circle(250,180,30,0,1);
glcd_rect(200,1,300,80,1,1);

Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: serkanpk - 26 Kasım 2010, 12:45:27
Alıntı yapılan: cdurakbasi - 24 Kasım 2010, 21:44:40
Alıntı yapılan: serkanpk - 24 Kasım 2010, 00:04:13
Devre pcb halinde.
Çalışma frekansı mesela 4-8-20MHZ denedim ama sonuç aynı.

modülünüzdeki chipin sel1 pininin lojik seviyesinin seçtiği komut setinin kodunuzunki ile aynı olduğundan emin olun (6800 veya 8080)

8835'in pdf dosyasını inceliyorum fakat nasıl bir düzeltme yapcağımı anlayamadım.
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: computerboy - 26 Kasım 2010, 13:02:01
#define GLCD_RST PIN_C0
#define GLCD_RD PIN_C4
#define GLCD_WR PIN_C3
#define GLCD_CS PIN_C1
#define GLCD_A0 PIN_C2

Üstad bu pinleri başka pinler ile değiştirip deneremisin bi bi ara bendede aynı tarzda bir sıkıntı olmuştu değiştirdim düzeldi.
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: serkanpk - 26 Kasım 2010, 13:03:57
oke hemen deniyorum. peki port olarak ne seçeyim?
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: computerboy - 26 Kasım 2010, 13:09:25
Önceki şemamdan baktım PORTE ve iki tanesinide PORTC.0 ve 1 ile kullanmışım ben.  komplesini portc ye aldığım zaman anlamsız bir sıkıntı çıkmıştı.
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: serkanpk - 26 Kasım 2010, 13:22:04
Alıntı yapılan: computerboy - 26 Kasım 2010, 13:09:25
Önceki şemamdan baktım PORTE ve iki tanesinide PORTC.0 ve 1 ile kullanmışım ben.  komplesini portc ye aldığım zaman anlamsız bir sıkıntı çıkmıştı.
Dediginiz şekilde düzenliyorum.hemen denemeyi yapıp bilgilendireceğim.
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: serkanpk - 26 Kasım 2010, 14:09:48
#define GLCD_RST PIN_C0
#define GLCD_RD PIN_E0//PIN_C4
#define GLCD_WR PIN_E1//PIN_C3
#define GLCD_CS PIN_E2//PIN_C1
#define GLCD_A0 PIN_C1//PIN_C2 

Şeklinde degiştirdim sorun devam ediyor...
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: computerboy - 26 Kasım 2010, 14:22:25
#define GLCD_RD PIN_E0//PIN_E0
#define GLCD_WR PIN_E1//PIN_E1
#define GLCD_CS PIN_E2//PIN_E2
#define GLCD_A0 PIN_C1//PIN_C0 
#define GLCD_RST PIN_C1

Bu pinler ile denermisiniz üstad gene olmuyorsa yazılım kaynaklı bir sıkıntı.
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: serkanpk - 26 Kasım 2010, 14:25:43
Alıntı yapılan: computerboy - 26 Kasım 2010, 14:22:25
#define GLCD_RD PIN_E0//PIN_E0
#define GLCD_WR PIN_E1//PIN_E1
#define GLCD_CS PIN_E2//PIN_E2
#define GLCD_A0 PIN_C1//PIN_C0 
#define GLCD_RST PIN_C1

Bu pinler ile denermisiniz üstad gene olmuyorsa yazılım kaynaklı bir sıkıntı.

#define GLCD_RST PIN_C1  << pinC0 'da bağlı digerleri zaten aynı.
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: serkanpk - 26 Kasım 2010, 14:33:41
Alıntı yapılan: computerboy - 26 Kasım 2010, 14:22:25
#define GLCD_RD PIN_E0//PIN_E0
#define GLCD_WR PIN_E1//PIN_E1
#define GLCD_CS PIN_E2//PIN_E2
#define GLCD_A0 PIN_C1//PIN_C0 
#define GLCD_RST PIN_C1

Bu pinler ile denermisiniz üstad gene olmuyorsa yazılım kaynaklı bir sıkıntı.
Senin lcdindeki çipset RA8835 miydi.Yazılımının lcd çipsetinin c dosyasını paylaşabilirmisin.
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: computerboy - 26 Kasım 2010, 14:41:03
Evet bakıyorum bulunca eklerim.
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: computerboy - 26 Kasım 2010, 14:55:23
Üstad kodları upload ettim.

Link: http://www.4shared.com/file/zBZsAGea/Ra8835.html
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: Konyali2 - 26 Kasım 2010, 16:34:58
PG12864 128X64 grafik lcd de aynı sorun başıma gelmişti enable gecikmesini artırarak çözmüştüm sizde de aynı problem var gibi gözüküyor. Çünkü bende de büyük fontlu yazılar ve geometrik şekiller bozuk çıkıyordu. Enable CS RW vs gibi uçların durum değiştirmleri arasında geçen sürelerle oynayın. Öncelikle enable gecikmesini deneyin
Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: celebrium - 26 Kasım 2010, 16:39:20
"modülünüzdeki chipin sel1 pininin lojik seviyesinin seçtiği komut setinin kodunuzunki ile aynı olduğundan emin olun (6800 veya 8080)" cdurakbasi

Doğru cevap bu ama şöyle biraz daha konuyu açıyım. LCD nin arka tarafındaki RAIO 8835 in üzerinde J68 ve J80 jumperları var ordaki 805 kılıflı kısa devre direnci J68 takılı yani 6800 seçili. Pic C deki alt kodlarda 8080 göre yazılmış. Kardeşimle beraber yaptığımız kodlar doğru şekilde çalışıyor..

Bu arada LCD yi Özdisan dan aldık. Fabrikasyon hali J68 de jumper var.

İnanın 1 haftadır  akşamları bu iş için uğraşıyoruz.

Şimdik sıra
T6963 lü 240x128 LCD de çalıştırıcaz.
Daha sonrasında bu kodları Flowcode programına entegre edicez :)

Bunuda yaptıktan sonra Matrix Multimedia firmasına yollıcam ordan tüm dünya faydalansın.

Ama önce bu sitede yayınlanacak tabiki :)

Bütün arkadaşlara verdikleri cevap ve emekleri için teşekkür ederiz.

Başlık: Ynt: PIC C 320x240 RA8835 + pic18f4620 için graphics.c'deki fonksiyonlar çalışmıyor.
Gönderen: celebrium - 26 Kasım 2010, 16:48:07
Bu arada konyalı kardeşim dediğin doğru onu KS 0108 i 10Mhz kristali (PIC18F4520) de 4x PLL yaparak 40Mhz de kullanıyorduk. İşlemcilerde sorun yaşanınca 20Mhz kristalle 2xPLL yapıp 40 Mhz e çıkarttık . Bu esnada bahsettiğin gibi aralara gecikme koymak gerekti.

Benzer sorunu bende yaşamıştım