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.

help me how to use graphical lcd with pic 16f877

Status
Not open for further replies.

ali nmr

Newbie level 1
Joined
Oct 22, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
egypt
Activity points
1,288
I am trying to procure a graphic LCD and interface it with pic16F877A . Can some one please guide me how to conect it with pic and please write the program for it "basic or assemple" (how to programming it)with basic (high level language)
my email "alinmr2222@yahoo.com"
 

what GLCD controller u are using? KS0107/8 or T6963C?
here is sample program from mikroelektronika in BASIC pro using KS0107/8 controller Graphic LCD

Code:
program Glcd_Test

' Glcd module connections
dim GLCD_DataPort as byte at PORTD

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

dim GLCD_CS1_Direction as sbit at TRISB0_bit
    GLCD_CS2_Direction as sbit at TRISB1_bit
    GLCD_RS_Direction  as sbit at TRISB2_bit
    GLCD_RW_Direction  as sbit at TRISB3_bit
    GLCD_EN_Direction  as sbit at TRISB4_bit
    GLCD_RST_Direction as sbit at TRISB5_bit
' End Glcd module connections

dim counter as byte
    someText as char[18]

sub procedure Delay2S()                ' 2 seconds delay sub function
  Delay_ms(2000)
end sub

main:
  'ANSEL  = 0                           ' Configure AN pins as digital I/O
  'ANSELH = 0

  Glcd_Init()                          ' Initialize Glcd
  Glcd_Fill(0x00)                      ' Clear Glcd

  while TRUE
    Glcd_Image(@truck_bmp)             ' Draw image
    Delay2S() delay2S()

    Glcd_Fill(0x00)                    ' Clear Glcd

    Glcd_Box(62,40,124,63,1)           ' Draw box
    Glcd_Fill(0x00)                      ' Clear Glcd
    Glcd_Rectangle(5,5,84,35,1)        ' Draw rectangle
    Glcd_Fill(0x00)                      ' Clear Glcd
    Glcd_Line(0, 0, 127, 63, 1)        ' Draw line
    Delay2S()
    counter = 5

    while (counter <= 59)              ' Draw horizontal and vertical lines
      Delay_ms(250)
      Glcd_V_Line(2, 54, counter, 1)
      Glcd_H_Line(2, 120, counter, 1)
      Counter = counter + 5
    wend

    Delay2S()

    Glcd_Fill(0x00)                         ' Clear Glcd

    Glcd_Set_Font(@Character8x7, 8, 7, 32)  ' Choose font "Character8x7"
    Glcd_Write_Text("mikroE", 1, 7, 2)      ' Write string

    for counter = 1 to 10                   ' Draw circles
      Glcd_Circle(63,32, 3*counter, 1)
    next counter
    Delay2S()

    Glcd_Box(10,20, 70,63, 2)               ' Draw box
    Delay2S()

    Glcd_Fill(0xFF)                         ' Fill 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, 5, 6, 2)         ' Write string
    delay2S()
  wend
end.

hope it help you...cheers

Added after 4 minutes:

and this for T6963C controller, again from mikroelektronika sample program written in BASIC Pro

Code:
program T6963C_240x128

include __Lib_T6963C_Consts
include einstein_bmp
include mikroe_bmp

' T6963C module connections
dim T6963C_dataPort as byte at PORTD                  ' DATA port

dim T6963C_ctrlwr as sbit at RC2_bit                 ' WR write signal
dim T6963C_ctrlrd as sbit at RC1_bit                 ' RD read signal
dim T6963C_ctrlcd as sbit at RC0_bit                 ' CD command/data signal
dim T6963C_ctrlrst as sbit at RC4_bit                ' RST reset signal
dim T6963C_ctrlwr_Direction as sbit at TRISC2_bit        ' WR write signal direction
dim T6963C_ctrlrd_Direction as sbit at TRISC1_bit        ' RD read signal direction
dim T6963C_ctrlcd_Direction as sbit at TRISC0_bit        ' CD command/data signal direction
dim T6963C_ctrlrst_Direction as sbit at TRISC4_bit       ' RST reset signal direction

' Signals not used by library, they are set in main sub function
dim T6963C_ctrlce as sbit at RC3_bit                 ' CE signal
dim T6963C_ctrlfs as sbit at RC6_bit                 ' FS signal
dim T6963C_ctrlmd as sbit at RC5_bit                 ' MD signal
dim T6963C_ctrlce_Direction as sbit at TRISC3_bit        ' CE signal direction
dim T6963C_ctrlfs_Direction as sbit at TRISC6_bit        ' FS signal direction
dim T6963C_ctrlmd_Direction as sbit at TRISC5_bit        ' MD signal direction
' End T6963C module connections

dim   panel as byte         ' current panel
          i as word         ' general purpose register
       curs as byte         ' cursor visibility
      cposx,
      cposy as word         ' cursor x-y position
      txtcols as byte       ' number of text coloms
      txt, txt1 as string[29]


main:
  txt1 = " EINSTEIN WOULD HAVE LIKED mE"
  txt  = " GLCD LIBRARY DEMO, WELCOME !"

  ANSEL  = 0                    ' Configure AN pins as digital I/O
  ANSELH = 0
  C1ON_bit = 0                  ' Disable comparators
  C2ON_bit = 0

  TRISB0_bit = 1                ' Set RB0 as input
  TRISB1_bit = 1                ' Set RB1 as input
  TRISB2_bit = 1                ' Set RB2 as input
  TRISB3_bit = 1                ' Set RB3 as input
  TRISB4_bit = 1                ' Set RB4 as input

  T6963C_ctrlce_Direction = 0
  T6963C_ctrlce = 0             ' Enable T6963C
  T6963C_ctrlfs_Direction = 0
  T6963C_ctrlfs = 0             ' Font Select 8x8
  T6963C_ctrlmd_Direction = 0
  T6963C_ctrlmd = 0             ' Column number select

  panel = 0
  i = 0
  curs = 0
  cposx = 0
  cposy = 0

  ' Initialize T6369C
  T6963C_init(240, 128, 8)

'   *
'   * Enable both graphics and text display at the same time
'   *
  T6963C_graphics(1)
  T6963C_text(1)

'   *
'   * Text messages
'   *
  T6963C_write_text(txt, 0, 0, T6963C_ROM_MODE_XOR)
  T6963C_write_text(txt1, 0, 15, T6963C_ROM_MODE_XOR)


'   *
'   * Cursor
'   *
  T6963C_cursor_height(8)       ' 8 pixel height
  T6963C_set_cursor(0, 0)       ' Move cursor to top left
  T6963C_cursor(0)              ' Cursor off

'   *
'   * Draw rectangles
'   *
  T6963C_rectangle(0, 0, 239, 127, T6963C_WHITE)
  T6963C_rectangle(20, 20, 219, 107, T6963C_WHITE)
  T6963C_rectangle(40, 40, 199, 87, T6963C_WHITE)
  T6963C_rectangle(60, 60, 179, 67, T6963C_WHITE)

'   *
'   * Draw a cross
'   *
  T6963C_line(0, 0, 239, 127, T6963C_WHITE)
  T6963C_line(0, 127, 239, 0, T6963C_WHITE)

'   *
'   * Draw solid boxes
'   *
  T6963C_box(0, 0, 239, 8, T6963C_WHITE)
  T6963C_box(0, 119, 239, 127, T6963C_WHITE)

'   *
'   * Draw circles
'   *
  T6963C_circle(120, 64, 10, T6963C_WHITE)
  T6963C_circle(120, 64, 30, T6963C_WHITE)
  T6963C_circle(120, 64, 50, T6963C_WHITE)
  T6963C_circle(120, 64, 70, T6963C_WHITE)
  T6963C_circle(120, 64, 90, T6963C_WHITE)
  T6963C_circle(120, 64, 110, T6963C_WHITE)
  T6963C_circle(120, 64, 130, T6963C_WHITE)

  T6963C_sprite(76, 4, @einstein, 88, 119)      ' Draw a sprite

  T6963C_setGrPanel(1)                          ' Select other graphic panel

  T6963C_sprite(0, 0,  @mikroe_bmp, 240, 64)    ' 240x128 can"t be stored in most of PIC16 MCUs
  T6963C_sprite(0, 64, @mikroe_bmp, 240, 64)    '   it is replaced with smaller picture 240x64
                                                '   Smaller picture is drawn two times

  while TRUE                                    ' Endless loop

    '*
    '* If PORTB_0 is pressed, toggle the display between graphic panel 0 and graphic 1
    '*

    if (RB0_bit <> 0) then
          T6963C_graphics(1)
          T6963C_text(0)
          Delay_ms(300)

    '*
    '* If PORTB_1 is pressed, display only graphic panel
    '*

    else
      if (RB1_bit <> 0) then
         Inc(panel)
         panel = panel and 1
         T6963C_setPtr((T6963C_grMemSize + T6963C_txtMemSize) * panel, T6963C_GRAPHIC_HOME_ADDRESS_SET)
         Delay_ms(300)

    '*
    '* If PORTB_2 is pressed, display only text panel
    '*
      else
        if (RB2_bit <> 0) then
          T6963C_graphics(0)
          T6963C_text(1)
          Delay_ms(300)

    '*
    '* If PORTB_3 is pressed, display text and graphic panels
    '*
        else
          if (RB3_bit <> 0) then
            T6963C_graphics(1)
            T6963C_text(1)
            Delay_ms(300)

    '*
    '*  If PORTB_4 is pressed, change cursor
    '*
          else
            if(RB4_bit <> 0) then
              Inc(curs)
              if (curs = 3) then
                curs = 0
              end if
              select case curs
                case 0
                       ' no cursor
                       T6963C_cursor(0)
                case 1
                       ' blinking cursor
                       T6963C_cursor(1)
                       T6963C_cursor_blink(1)
                case 2
                       ' non blinking cursor
                       T6963C_cursor(1)
                       T6963C_cursor_blink(0)
              end select  'case
                Delay_ms(300)

            end if
          end if
        end if
      end if
    end if

      '*
      '* Move cursor, even if not visible
      '*
      Inc(cposx)
      if (cposx = T6963C_txtCols) then
        cposx = 0
        Inc(cposy)
        if (cposy = T6963C_grHeight / T6963C_CHARACTER_HEIGHT) then
          cposy = 0
        end if
      end if
      T6963C_set_cursor(cposx, cposy)

      Delay_ms(100)
  wend
end.
 
  • Like
Reactions: mlc89

    mlc89

    Points: 2
    Helpful Answer Positive Rating
Can you please help me. I need T6963C code for Atmega32
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top