LCD conections

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hy.
The following instructions represent the initialization of a LCD.
Can someone tell me if there is another way to set this bits and how ?
Thank you.

// Glcd module connections
sbit GLCD_CS1 at PORTD2_bit;
sbit GLCD_CS2 at PORTD3_bit;
sbit GLCD_RS at PORTD4_bit;
sbit GLCD_RW at PORTD5_bit;
sbit GLCD_EN at PORTD6_bit;
sbit GLCD_RST at PORTD7_bit;
sbit GLCD_CS1_Direction at DDD2_bit;
sbit GLCD_CS2_Direction at DDD3_bit;
sbit GLCD_RS_Direction at DDD4_bit;
sbit GLCD_RW_Direction at DDD5_bit;
sbit GLCD_EN_Direction at DDD6_bit;
sbit GLCD_RST_Direction at DDD7_bit;

// Touch Panel module connections
sbit DriveA at PORTA2_bit;
sbit DriveB at PORTA3_bit;
sbit DriveA_Direction at DDA2_bit;
sbit DriveB_Direction at DDA3_bit;

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Obviously the SC, RS, WR and EN bits will always need to be set or cleared individually, so there is not much else you can do with them. The direction bits are all always set to output, so you could set all those bits in one statement in your initialization code.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You'll need to try better than than. Without a more complete description of what you are trying to accomplish, the hardware you are using, and the tool chain in use, there is nothing anyone here can do, except perhaps make a guess, which I will do in a moment.

You should provide pertinent information, such as...

    What is the LCD make and model?

    What is its controller?

    What MCU are you using?

    What about showing us the initialization code, not just how the stuff is connected?

Without this sort information, I will make a wild guess that you will not get much help.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I use the Graphic LCD with screen resolution 128x64 pixels, ATMEGA16 16PU 1010K microcontroller.
My problem is that I dont understand the above code.
So this lines :
"sbit GLCD_CS1 at PORTD2_bit" is equivalent with "PORTD |= (1<<2)";

"sbit GLCD_CS1_Direction at DDD2_bit" is equivalent with "DDD2 |= (1<<2)";

"sbit DriveA at PORTA2_bit" is equvalent with "PORTA |= (1<<2)"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

My problem is that I dont understand the above code.

This suggests you didn't write it yourself. So where did you get it from?

Quote:
"sbit GLCD_CS1 at PORTD2_bit" is equivalent with "PORTD |= (1<<2)";

There is no way to tell, sice we have not seen the rest of the code. For sure, as it stands on it's own it is not even legal C.

I suspect that this is either not actual code but merely some pseudo-notation, or that there are e.g. macros named "sbit" and "at" defined somewhere else in the code, or that this is written in some obscure other language than C. (Since here are semi-colons at the end of those "statements", it does not look like BASIC.)

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

So where did you get it from?

You aren't going to like the answer! Google says:

http://www.mikroe.com/download/e...

If OP's desire here is to drive a KS0108 there are lots of better libraries that will work in real C compilers.

Search "Fabian Maximillian Thiele" or "the Polish code".

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a developement board from Mikroelektronika, Easy AVR6.
The entire code :

char GLCD_DataPort at PORTC;
char GLCD_DataPort_Direction at DDRC;

sbit GLCD_CS1 at PORTD2_bit;
sbit GLCD_CS2 at PORTD3_bit;
sbit GLCD_RS  at PORTD4_bit;
sbit GLCD_RW  at PORTD5_bit;
sbit GLCD_EN  at PORTD6_bit;
sbit GLCD_RST at PORTD7_bit;
sbit GLCD_CS1_Direction at DDD2_bit;
sbit GLCD_CS2_Direction at DDD3_bit;
sbit GLCD_RS_Direction  at DDD4_bit;
sbit GLCD_RW_Direction  at DDD5_bit;
sbit GLCD_EN_Direction  at DDD6_bit;
sbit GLCD_RST_Direction at DDD7_bit;
// End Glcd module connections

// Touch Panel module connections
//sbit DriveA at PORTA2_bit;
//sbit DriveB at PORTA3_bit;
//sbit DriveA_Direction at DDA2_bit;
//sbit DriveB_Direction at DDA3_bit;
// End Touch Panel module connections

sbit DriveA at PORTA2_bit;
sbit DriveB at PORTA3_bit;
sbit DriveA_Direction at DDA2_bit;
sbit DriveB_Direction at DDA3_bit;

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() {
  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(57, 917, 138, 877);           // 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;
                   }
        }
      }
    }
  }
}
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh bad luck. So it's not just their code you are trying to use but also their "C compiler"? In that case I'd really recommend posting the question on the Mikroe forums as very few people here use that "quaint" compiler. (I see there's even a forum specifically for "Visual GLCD Software").

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh, Mikroe C. I won't take any part in that - AFAIAC it should not be touched with a ten-foot pole.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]