Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Pic18f452 does not work with GLCD

Status
Not open for further replies.

mamech

Full Member level 3
Joined
Nov 9, 2010
Messages
176
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Activity points
3,135
Hello

I am using easypic6 .

I tried the GLCD example in mikroC on pic16887, and it worked well.

I tried to use PIC18F452 and I made the following modifications to the code:
Code:
/*
 * Project name:
     GLCD_Test (Demonstration of the GLCD library routines)
 * Copyright:
     (c) Mikroelektronika, 2009.
 * Revision History:
     20081218:
       - initial release;
       - 20090720 - modified by Slavisa Zlatanovic;
 * Description:
     This is a simple demonstration of the GLCD library routines:
     - Init and Clear (pattern fill)
     - Image display
     - Basic geometry - lines, circles, boxes and rectangles
     - Text display and handling
 * Test configuration:
     MCU:             PIC16F887
                      http://ww1.microchip.com/downloads/en/DeviceDoc/41291F.pdf
     Dev.Board:       EasyPIC6 - ac:GLCD
                      http://www.mikroe.com/eng/products/view/297/easypic6-development-system/
     Oscillator:      HS, 08.0000 MHz
     Ext. Modules:    GLCD 128x64, KS108/107 controller
                      http://www.mikroe.com/eng/categories/view/43/components/#other
     SW:              mikroC PRO for PIC
                      http://www.mikroe.com/eng/products/view/7/mikroc-pro-for-pic/
 * Notes:
     - Turn on GLCD backlight switch SW6.8.
*/

//Declarations------------------------------------------------------------------
const code char truck_bmp[1024];
//--------------------------------------------------------------end-declarations

// Glcd module connections
char GLCD_DataPort at PORTD;

sbit GLCD_CS1 at RB0_bit;
sbit GLCD_CS2 at RB1_bit;
sbit GLCD_RS  at RB2_bit;
sbit GLCD_RW  at RB3_bit;
sbit GLCD_EN  at RB4_bit;
sbit GLCD_RST at RB5_bit;

sbit GLCD_CS1_Direction at TRISB0_bit;
sbit GLCD_CS2_Direction at TRISB1_bit;
sbit GLCD_RS_Direction  at TRISB2_bit;
sbit GLCD_RW_Direction  at TRISB3_bit;
sbit GLCD_EN_Direction  at TRISB4_bit;
sbit GLCD_RST_Direction at TRISB5_bit;
// End Glcd module connections

void delay2S(){                                    // 2 seconds delay function
  Delay_ms(2000);
}

void main() {                       
  #define DRAWING_DEMO                             // Uncomment this line to see drawing routines demo
  //#define TEXT_DEMO                              // Uncomment this line to see text routines demo

  unsigned short counter;
  char *someText;

    ADCON1 = 0b0110;      [B]//  I closed here All analog pins according to the data sheet[/B]
 
// ANSEL  = 0;                                      // Configure AN pins as digital
  //ANSELH = 0;
  //C1ON_bit = 0;                                    // Disable comparators
  //C2ON_bit = 0;

  Glcd_Init();                                     // Initialize GLCD
  Glcd_Fill(0x00);                                 // Clear GLCD

  while(1) {
    Glcd_Image(truck_bmp);                         // Draw image
    Delay2s(); Delay2s();
    Glcd_fill(0x00);                                  // Clear GLCD
    Glcd_PartialImage(0,0,68,30,128,64,truck_bmp);    // Partial image
    Delay_ms(500);
    Glcd_PartialImage(24,16,68,30,128,64,truck_bmp);
    Delay_ms(500);
    Glcd_PartialImage(56,34,68,30,128,64,truck_bmp);
    Delay2s(); Delay2s();
    Glcd_Fill(0x00);                               // Clear GLCD

    #ifdef DRAWING_DEMO
      Glcd_Box(62,40,124,56,1);                    // Draw box
      Glcd_Rectangle(5,5,84,35,1);                 // Draw rectangle
      Delay_ms(1000);
      Glcd_Rectangle_Round_Edges(2,2,87,38,7,1);
      Delay_ms(1000);
      Glcd_Rectangle_Round_Edges_Fill(8,8,81,32,12,1);
      Delay_ms(1000);
      Glcd_Line(0, 0, 127, 63, 1);                 // Draw line
      Delay2s();

      for(counter = 5; counter < 60; counter+=5 ){ // Draw horizontal and vertical lines
        Delay_ms(250);
        Glcd_V_Line(2, 54, counter, 1);
        Glcd_H_Line(2, 120, counter, 1);
      }
      Delay2s();

      Glcd_Fill(0x00);                             // Clear Glcd

      for (counter = 1; counter <= 10; counter++)  // Draw circles
        Glcd_Circle(63,32, 3*counter, 1);
      Delay2s();

      for (counter = 1; counter <= 10; counter++)  // Draw circles
        Glcd_Circle_Fill(63,32, 3*counter, 1);
      Delay2s();

      Glcd_Box(12,20, 70,57, 2);                   // Draw box
      Delay2s();

      Glcd_Fill(0xFF);                             // Fill Glcd
    #endif

    #ifdef TEXT_DEMO
      Glcd_Set_Font(Character8x7, 8, 7, 32);       // Choose font, see __Lib_GLCDFonts.c in Uses folder
      Glcd_Write_Text("TEXT DEMO", 24, 3, 2);      // Write string
      Delay2s();
      Glcd_Fill(0x00);                             // Clear Glcd

      Glcd_Set_Font(Character8x7, 8, 7, 32);       // Change font
      someText = "8x7 Font";
      Glcd_Write_Text(someText, 5, 0, 2);          // Write string
      Delay2s();

      Glcd_Set_Font(System3x5, 3, 5, 32);          // Change font
      someText = "3X5 CAPITALS ONLY";
      Glcd_Write_Text(someText, 60, 2, 2);         // Write string
      Delay2s();

      Glcd_Set_Font(font5x7, 5, 7, 32);            // Change font
      someText = "5x7 Font";
      Glcd_Write_Text(someText, 5, 4, 2);          // Write string
      Delay2s();

      Glcd_Set_Font(FontSystem5x7_v2, 5, 7, 32);   // Change font
      someText = "5x7 Font (v2)";
      Glcd_Write_Text(someText, 50, 6, 2);         // Write string
      Delay2s();
    #endif
  }
}



There is no compilation error , but The glcd displays a big filled rectangle that fills all the screen !!!


What should be the source of this error ?

Thanks


Attachments : PIC18F452 Datasheet

View attachment 39564c.pdf
 
Last edited:

Can you try set the PCFG3:pCFG0 independently? It might work :)
 

Can you try set the PCFG3:pCFG0 independently? It might work :)

Do you mean like this :

Code:
/*
 * Project name:
     GLCD_Test (Demonstration of the GLCD library routines)
 * Copyright:
     (c) Mikroelektronika, 2009.
 * Revision History:
     20081218:
       - initial release;
       - 20090720 - modified by Slavisa Zlatanovic;
 * Description:
     This is a simple demonstration of the GLCD library routines:
     - Init and Clear (pattern fill)
     - Image display
     - Basic geometry - lines, circles, boxes and rectangles
     - Text display and handling
 * Test configuration:
     MCU:             PIC16F887
                      http://ww1.microchip.com/downloads/en/DeviceDoc/41291F.pdf
     Dev.Board:       EasyPIC6 - ac:GLCD
                      http://www.mikroe.com/eng/products/view/297/easypic6-development-system/
     Oscillator:      HS, 08.0000 MHz
     Ext. Modules:    GLCD 128x64, KS108/107 controller
                      http://www.mikroe.com/eng/categories/view/43/components/#other
     SW:              mikroC PRO for PIC
                      http://www.mikroe.com/eng/products/view/7/mikroc-pro-for-pic/
 * Notes:
     - Turn on GLCD backlight switch SW6.8.
*/

//Declarations------------------------------------------------------------------
const code char truck_bmp[1024];
//--------------------------------------------------------------end-declarations

// Glcd module connections
char GLCD_DataPort at PORTD;

sbit GLCD_CS1 at RB0_bit;
sbit GLCD_CS2 at RB1_bit;
sbit GLCD_RS  at RB2_bit;
sbit GLCD_RW  at RB3_bit;
sbit GLCD_EN  at RB4_bit;
sbit GLCD_RST at RB5_bit;

sbit GLCD_CS1_Direction at TRISB0_bit;
sbit GLCD_CS2_Direction at TRISB1_bit;
sbit GLCD_RS_Direction  at TRISB2_bit;
sbit GLCD_RW_Direction  at TRISB3_bit;
sbit GLCD_EN_Direction  at TRISB4_bit;
sbit GLCD_RST_Direction at TRISB5_bit;
// End Glcd module connections

void delay2S(){                                    // 2 seconds delay function
  Delay_ms(2000);
}

void main() {                       
 // #define DRAWING_DEMO                             // Uncomment this line to see drawing routines demo
  #define TEXT_DEMO                              // Uncomment this line to see text routines demo

  unsigned short counter;
  char *someText;
  //  ADCON1 = 0x07;
    PCFG0_bit = 0;
    PCFG1_bit = 1;
    PCFG2_bit = 1;
    PCFG3_bit = 1;
    TRISA = 0;

 // ANSEL  = 0;                                      // Configure AN pins as digital
  //ANSELH = 0;
  //C1ON_bit = 0;                                    // Disable comparators
  //C2ON_bit = 0;
  CCP1CON = 0;
  CCP2CON = 0;

  Glcd_Init();                                     // Initialize GLCD
  Glcd_Fill(0x00);                                 // Clear GLCD
  Delay_ms(2000);
  Glcd_Fill(0xFF);
  Delay_ms(2000);
  Glcd_Fill(0x00);                                 // Clear GLCD
  Delay_ms(2000);
  while(1) {
    Glcd_Image(truck_bmp);                         // Draw image
    Delay2s(); Delay2s();
    Glcd_fill(0x00);                                  // Clear GLCD
    Glcd_PartialImage(0,0,68,30,128,64,truck_bmp);    // Partial image
    Delay_ms(500);
    Glcd_PartialImage(24,16,68,30,128,64,truck_bmp);
    Delay_ms(500);
    Glcd_PartialImage(56,34,68,30,128,64,truck_bmp);
    Delay2s(); Delay2s();
    Glcd_Fill(0x00);                               // Clear GLCD

    #ifdef DRAWING_DEMO
      Glcd_Box(62,40,124,56,1);                    // Draw box
      Glcd_Rectangle(5,5,84,35,1);                 // Draw rectangle
      Delay_ms(1000);
      Glcd_Rectangle_Round_Edges(2,2,87,38,7,1);
      Delay_ms(1000);
      Glcd_Rectangle_Round_Edges_Fill(8,8,81,32,12,1);
      Delay_ms(1000);
      Glcd_Line(0, 0, 127, 63, 1);                 // Draw line
      Delay2s();

      for(counter = 5; counter < 60; counter+=5 ){ // Draw horizontal and vertical lines
        Delay_ms(250);
        Glcd_V_Line(2, 54, counter, 1);
        Glcd_H_Line(2, 120, counter, 1);
      }
      Delay2s();

      Glcd_Fill(0x00);                             // Clear Glcd

      for (counter = 1; counter <= 10; counter++)  // Draw circles
        Glcd_Circle(63,32, 3*counter, 1);
      Delay2s();

      for (counter = 1; counter <= 10; counter++)  // Draw circles
        Glcd_Circle_Fill(63,32, 3*counter, 1);
      Delay2s();

      Glcd_Box(12,20, 70,57, 2);                   // Draw box
      Delay2s();

      Glcd_Fill(0xFF);                             // Fill Glcd
    #endif

    #ifdef TEXT_DEMO
      Glcd_Set_Font(Character8x7, 8, 7, 32);       // Choose font, see __Lib_GLCDFonts.c in Uses folder
      Glcd_Write_Text("TEXT DEMO", 24, 3, 2);      // Write string
      Delay2s();
      Glcd_Fill(0x00);                             // Clear Glcd

      Glcd_Set_Font(Character8x7, 8, 7, 32);       // Change font
      someText = "8x7 Font";
      Glcd_Write_Text(someText, 5, 0, 2);          // Write string
      Delay2s();

      Glcd_Set_Font(System3x5, 3, 5, 32);          // Change font
      someText = "3X5 CAPITALS ONLY";
      Glcd_Write_Text(someText, 60, 2, 2);         // Write string
      Delay2s();

      Glcd_Set_Font(font5x7, 5, 7, 32);            // Change font
      someText = "5x7 Font";
      Glcd_Write_Text(someText, 5, 4, 2);          // Write string
      Delay2s();

      Glcd_Set_Font(FontSystem5x7_v2, 5, 7, 32);   // Change font
      someText = "5x7 Font (v2)";
      Glcd_Write_Text(someText, 50, 6, 2);         // Write string
      Delay2s();
    #endif
  }
}

Still nothing works : )
 

Do you mean like this :

Code:
/*
 * Project name:
     GLCD_Test (Demonstration of the GLCD library routines)
 * Copyright:
     (c) Mikroelektronika, 2009.
 * Revision History:
     20081218:
       - initial release;
       - 20090720 - modified by Slavisa Zlatanovic;
 * Description:
     This is a simple demonstration of the GLCD library routines:
     - Init and Clear (pattern fill)
     - Image display
     - Basic geometry - lines, circles, boxes and rectangles
     - Text display and handling
 * Test configuration:
     MCU:             PIC16F887
                      http://ww1.microchip.com/downloads/en/DeviceDoc/41291F.pdf
     Dev.Board:       EasyPIC6 - ac:GLCD
                      http://www.mikroe.com/eng/products/view/297/easypic6-development-system/
     Oscillator:      HS, 08.0000 MHz
     Ext. Modules:    GLCD 128x64, KS108/107 controller
                      http://www.mikroe.com/eng/categories/view/43/components/#other
     SW:              mikroC PRO for PIC
                      http://www.mikroe.com/eng/products/view/7/mikroc-pro-for-pic/
 * Notes:
     - Turn on GLCD backlight switch SW6.8.
*/

//Declarations------------------------------------------------------------------
const code char truck_bmp[1024];
//--------------------------------------------------------------end-declarations

// Glcd module connections
char GLCD_DataPort at PORTD;

sbit GLCD_CS1 at RB0_bit;
sbit GLCD_CS2 at RB1_bit;
sbit GLCD_RS  at RB2_bit;
sbit GLCD_RW  at RB3_bit;
sbit GLCD_EN  at RB4_bit;
sbit GLCD_RST at RB5_bit;

sbit GLCD_CS1_Direction at TRISB0_bit;
sbit GLCD_CS2_Direction at TRISB1_bit;
sbit GLCD_RS_Direction  at TRISB2_bit;
sbit GLCD_RW_Direction  at TRISB3_bit;
sbit GLCD_EN_Direction  at TRISB4_bit;
sbit GLCD_RST_Direction at TRISB5_bit;
// End Glcd module connections

void delay2S(){                                    // 2 seconds delay function
  Delay_ms(2000);
}

void main() {                       
 // #define DRAWING_DEMO                             // Uncomment this line to see drawing routines demo
  #define TEXT_DEMO                              // Uncomment this line to see text routines demo

  unsigned short counter;
  char *someText;
  //  ADCON1 = 0x07;
    PCFG0_bit = 0;
    PCFG1_bit = 1;
    PCFG2_bit = 1;
    PCFG3_bit = 1;
    TRISA = 0;

 // ANSEL  = 0;                                      // Configure AN pins as digital
  //ANSELH = 0;
  //C1ON_bit = 0;                                    // Disable comparators
  //C2ON_bit = 0;
  CCP1CON = 0;
  CCP2CON = 0;

  Glcd_Init();                                     // Initialize GLCD
  Glcd_Fill(0x00);                                 // Clear GLCD
  Delay_ms(2000);
  Glcd_Fill(0xFF);
  Delay_ms(2000);
  Glcd_Fill(0x00);                                 // Clear GLCD
  Delay_ms(2000);
  while(1) {
    Glcd_Image(truck_bmp);                         // Draw image
    Delay2s(); Delay2s();
    Glcd_fill(0x00);                                  // Clear GLCD
    Glcd_PartialImage(0,0,68,30,128,64,truck_bmp);    // Partial image
    Delay_ms(500);
    Glcd_PartialImage(24,16,68,30,128,64,truck_bmp);
    Delay_ms(500);
    Glcd_PartialImage(56,34,68,30,128,64,truck_bmp);
    Delay2s(); Delay2s();
    Glcd_Fill(0x00);                               // Clear GLCD

    #ifdef DRAWING_DEMO
      Glcd_Box(62,40,124,56,1);                    // Draw box
      Glcd_Rectangle(5,5,84,35,1);                 // Draw rectangle
      Delay_ms(1000);
      Glcd_Rectangle_Round_Edges(2,2,87,38,7,1);
      Delay_ms(1000);
      Glcd_Rectangle_Round_Edges_Fill(8,8,81,32,12,1);
      Delay_ms(1000);
      Glcd_Line(0, 0, 127, 63, 1);                 // Draw line
      Delay2s();

      for(counter = 5; counter < 60; counter+=5 ){ // Draw horizontal and vertical lines
        Delay_ms(250);
        Glcd_V_Line(2, 54, counter, 1);
        Glcd_H_Line(2, 120, counter, 1);
      }
      Delay2s();

      Glcd_Fill(0x00);                             // Clear Glcd

      for (counter = 1; counter <= 10; counter++)  // Draw circles
        Glcd_Circle(63,32, 3*counter, 1);
      Delay2s();

      for (counter = 1; counter <= 10; counter++)  // Draw circles
        Glcd_Circle_Fill(63,32, 3*counter, 1);
      Delay2s();

      Glcd_Box(12,20, 70,57, 2);                   // Draw box
      Delay2s();

      Glcd_Fill(0xFF);                             // Fill Glcd
    #endif

    #ifdef TEXT_DEMO
      Glcd_Set_Font(Character8x7, 8, 7, 32);       // Choose font, see __Lib_GLCDFonts.c in Uses folder
      Glcd_Write_Text("TEXT DEMO", 24, 3, 2);      // Write string
      Delay2s();
      Glcd_Fill(0x00);                             // Clear Glcd

      Glcd_Set_Font(Character8x7, 8, 7, 32);       // Change font
      someText = "8x7 Font";
      Glcd_Write_Text(someText, 5, 0, 2);          // Write string
      Delay2s();

      Glcd_Set_Font(System3x5, 3, 5, 32);          // Change font
      someText = "3X5 CAPITALS ONLY";
      Glcd_Write_Text(someText, 60, 2, 2);         // Write string
      Delay2s();

      Glcd_Set_Font(font5x7, 5, 7, 32);            // Change font
      someText = "5x7 Font";
      Glcd_Write_Text(someText, 5, 4, 2);          // Write string
      Delay2s();

      Glcd_Set_Font(FontSystem5x7_v2, 5, 7, 32);   // Change font
      someText = "5x7 Font (v2)";
      Glcd_Write_Text(someText, 50, 6, 2);         // Write string
      Delay2s();
    #endif
  }
}

Still nothing works : )

Yup. Is there anything else you modify?
 

Actually, I am confused. I thought that this should be easy. The program works on PIC16887, what does not it work on PIC18f452 ??
 

Did you set the same clock setting. If you do, most likely, there are additional settings of the registers as PORTA and PORTB in PIC18F is multi-purpose port
 

Did you set the same clock setting. If you do, most likely, there are additional settings of the registers as PORTA and PORTB in PIC18F is multi-purpose port



Alhamdulillah . I have found where the problem was

There where 2 options that should be changed in mikroC before compilation, the first one is to change the Oscillator to HS, and the second is to disable low voltage programming bit.

Now it works well with the GLCD example.

But when I tried the touch panel example after making some modifications to suit pic18F452(as it is originally designed to suit pic16F887), I got the writings clear on the screen, but the touch does not work.

I suppose that the configuration of ADCON1 is the source of the problem now.

As I understand, it needs to change A0 and A1 to analog inputs, while all other port A pins are digital output.

So this is the code:

Code:
/*
* Project name:
     TouchPanelWrite (Demo for working with TouchPanel Controller)
* Copyright:
     (c) Mikroelektronika, 2010.
* Revision History:
     20100203:
       - initial release;
* Description:
     This code works with TouchPanel and GLCD. Two digital output and
     two analog input signals are used for communication with TouchPanel.
     This example is for writing on the screen, calibration constants for touch
     panel are set via library function.
* Test configuration:
     MCU:             PIC16F887
                      http://ww1.microchip.com/downloads/en/DeviceDoc/41291F.pdf
     Dev.Board:       EasyPIC6 - ac:Touch_Panel
                      http://www.mikroe.com/eng/products/view/297/easypic6-development-system/
     Oscillator:      HS, 08.0000 MHz
     Ext. Modules:    GLCD 128x64, Touch Panel
                      http://www.mikroe.com/eng/categories/view/43/components/
     SW:              mikroC PRO for PIC
                      http://www.mikroe.com/eng/products/view/7/mikroc-pro-for-pic/
* Notes:
     - Turn on GLCD backlight switch SW8.8.
     - Turn on TouchPanel Controller switches SW9.5, SW9.6, SW9.7 and SW9.8.
     - Turn off PORTA LEDs SW9.1.
*/

// Glcd module connections
char GLCD_DataPort at PORTD;

sbit GLCD_CS1 at RB0_bit;
sbit GLCD_CS2 at RB1_bit;
sbit GLCD_RS  at RB2_bit;
sbit GLCD_RW  at RB3_bit;
sbit GLCD_EN  at RB4_bit;
sbit GLCD_RST at RB5_bit;

sbit GLCD_CS1_Direction at TRISB0_bit;
sbit GLCD_CS2_Direction at TRISB1_bit;
sbit GLCD_RS_Direction  at TRISB2_bit;
sbit GLCD_RW_Direction  at TRISB3_bit;
sbit GLCD_EN_Direction  at TRISB4_bit;
sbit GLCD_RST_Direction at TRISB5_bit;
// End Glcd module connections

// Touch Panel module connections
sbit DriveA at RC0_bit;
sbit DriveB at RC1_bit;
sbit DriveA_Direction at TRISC0_bit;
sbit DriveB_Direction at TRISC1_bit;
// End Touch Panel module connections

bit          write_erase;
char         pen_size;
char write_msg[] = "WRITE";                                // GLCD menu messages
char clear_msg[] = "CLEAR";
char erase_msg[] = "ERASE";
unsigned int x_coord, y_coord;

void Initialize() {
  /*ANSEL  = 3;                                              // Configure AN0 and AN1 pins as analog inputs
  ANSELH = 0;                                              // and other AN pins as digital I/O
  TRISA  = 3;

  C1ON_bit = 0;                                            // Disable comparators
  C2ON_bit = 0; */
 
  ADCON1 = 4;   //This is the closest configuration to ANSEL =3
                         //but here AN3 also will be analog
CCP1CON = 0;
   CCP2CON = 0;
TRISA = 0b00000011;

  Glcd_Init();                                             // Initialize GLCD
  Glcd_Fill(0);                                            // Clear GLCD

  ADC_Init();                                              // Initialize ADC
  TP_Init(128, 64, 0, 1);                                  // Initialize touch panel
  TP_Set_ADC_Threshold(900);                               // Set touch panel ADC threshold
}

void main() {

  Initialize();
 
  // You can get calibration constants using touch panel calibration example
  TP_Set_Calibration_Consts(76, 917, 108, 906);           // Set calibration constants

  Glcd_Write_Text("WRITE ON SCREEN", 20, 5, 1) ;
  Delay_ms(1000);

  Glcd_Fill(0);                                            // Clear GLCD
  Glcd_V_Line(0,7,0,1);
  Glcd_Write_Text(clear_msg,1,0,0);
  Glcd_V_Line(0,7,97,1);
  Glcd_Write_Text(erase_msg,98,0,0);

  // Pen Menu:
  Glcd_Rectangle(41,0,52,9,1);
  Glcd_Box(45,3,48,6,1);
  Glcd_Rectangle(63,0,70,7,1);
  Glcd_Box(66,3,67,4,1);
  Glcd_Rectangle(80,0,86,6,1);
  Glcd_Dot(83,3,1);

  write_erase = 1;
  pen_size = 1;
  while (1) {

    if (TP_Press_Detect()) {
      // After a PRESS is detected read X-Y and convert it to 128x64 space
      if (TP_Get_Coordinates(&x_coord, &y_coord) == 0) {

        if ((x_coord < 31) && (y_coord < 8)) {

          Glcd_Fill(0);

          // Pen Menu:
          Glcd_Rectangle(41,0,52,9,1);
          Glcd_Box(45,3,48,6,1);
          Glcd_Rectangle(63,0,70,7,1);
          Glcd_Box(66,3,67,4,1);
          Glcd_Rectangle(80,0,86,6,1);
          Glcd_Dot(83,3,1);

          Glcd_V_Line(0,7,0,1);
          Glcd_Write_Text(clear_msg,1,0,0);
          Glcd_V_Line(0,7,97,1);
          if (write_erase)
            Glcd_Write_Text(erase_msg,98,0,0);
          else
            Glcd_Write_Text(write_msg,98,0,0);
          }

        // If write/erase is pressed
        if ((x_coord > 96) && (y_coord < 8)) {
          if (write_erase) {
            write_erase = 0;
            Glcd_Write_Text(write_msg,98,0,0);
            Delay_ms(500);
            }
          else {
            write_erase = 1;
            Glcd_Write_Text(erase_msg,98,0,0);
            Delay_ms(500);
            }
          }

        // If pen size is selected
        if ((x_coord >= 41) && (x_coord <= 52) && (y_coord <= 9))
          pen_size = 3;

        if ((x_coord >= 63) && (x_coord <= 70) && (y_coord <= 7))
          pen_size = 2;

        if ((x_coord >= 80) && (x_coord <= 86) && (y_coord <= 6))
          pen_size = 1;

        if (y_coord < 11)
          continue;

        switch (pen_size) {
          case 1 : {
                     if ( (x_coord >= 0) && (y_coord >= 0) && (x_coord <= 127) && (y_coord <= 63) )
                       Glcd_Dot(x_coord, y_coord, write_erase);
                     break;
                   }
          case 2 : {
                     if ( (x_coord >= 0) && (y_coord >= 0) && (x_coord <= 127-1) && (y_coord <= 63-1) )
                       Glcd_Box(x_coord, y_coord, x_coord + 1, y_coord + 1, write_erase);
                     break;
                   }
          case 3 : {
                     if ( (x_coord >= 1) && (y_coord >= 1) && (x_coord <= 127-2) && (y_coord <= 63-2) )
                       Glcd_Box(x_coord-1, y_coord-1, x_coord + 2, y_coord + 2, write_erase);
                     break;
                   }
        }
      }
    }
  }
}



So, what do you think ?


Thanks for your time
 

Try to check your ADC channel whether it is the right one :)
 

have made a lot of tries, and I revised the part of ADC in data sheet, but still nothing works.

Do not you have a code of pic18f452 of touch screen application, so I may know what is wrong with my code?



Do anyone here have easypic6 board and want to help ?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top