Writing data to the graphic display using serial interface instead of parallel

Discussion in 'Embedded Systems and Microcontrollers' started by RG23, Jun 6, 2012.

  1. RG23

    Thread Starter Active Member

    Dec 6, 2010
    301
    2
    I used the following code while displaying the data to the graphic lcd

    movlw 0x80//////cursor position
    movwf PORTD
    call SND_CMD

    movlw 0x35///////data
    movwf PORTD
    call SND_DTA

    The above statements allowed me to display the required pixels on graphic display but that was using the parallel interface to the LCD

    But now I have to use serial interface and so I cannot send the entire byte to PORTD

    I am not able to figure out how can I display the data as I did before

    The command and data subroutines I used for the parallel interface are as follows:
    /////PORTB,1--> Data or Command

    /////PORTB,2--> RW

    /////PORTB,4--> Enable


    /////PORTB,5--> Reset
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; WRITE COMMANDS TO LCD
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    SND_CMD:
    bcf PORTB,1
    bcf PORTB,2

    bcf PORTB,5

    bsf PORTB,4
    nop
    nop
    nop
    nop
    bcf PORTB,4
    bsf PORTB,5
    return
    ;}
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; WRITE DATA TO LCD
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    SND_DTA:
    ;{
    bsf PORTB,1
    bcf PORTB,2

    bcf PORTB,5

    bsf PORTB,4
    nop
    nop
    nop
    nop
    bcf PORTB,4
    bsf PORTB,5
    return

    If anyone has an idea, please let me know

    Thanks
     
    Last edited: Jun 7, 2012
  2. absf

    Senior Member

    Dec 29, 2010
    1,490
    371
    You can "stream" or "bit bang" the data from port D to a shift register like 74HC595 which connects to the data lines of your GLCD. This scheme would used up 2 port pins from your PIC. Look at the example here.

    http://embedded-lab.com/blog/?p=30

    In the example, only RS and 4 data bits are shifted out. But in your case you can shift out all 8 bits ignoring RS as it was already taken care of by your PORT B,1.

    Allen
     
    Last edited: Jun 6, 2012
  3. RG23

    Thread Starter Active Member

    Dec 6, 2010
    301
    2
    The graphic display I am using has only one Serial data input pin.
    I dont think shift register like 74HC595 can fix the problem
     
  4. RG23

    Thread Starter Active Member

    Dec 6, 2010
    301
    2
    I could not find any example of serial interface to the graphic display

    If anyone has an idea please let me know
    Thanks
     
  5. hexreader

    Active Member

    Apr 16, 2011
    249
    82
    I think we will need some information on this mysterious graphic display that you are using, otherwise any advice would be just more guesswork.

    Can you provide a link to the datasheet?

    Sparkfun sell async serial input GLCDs which come with example code. Is this what you are using?

    Which PIC are you using? (I assume this is PIC code, as it looks like it)
     
    Last edited: Jun 7, 2012
  6. RG23

    Thread Starter Active Member

    Dec 6, 2010
    301
    2
  7. hexreader

    Active Member

    Apr 16, 2011
    249
    82
    That GLCD uses SPI protocol.

    It needs Clock, Data data/cmd and Select. 4 input wires (5 if you use reset), not one.

    Looks very specialised to me. I have no experience of that display, or of that PIC.

    I suspect that you may be out of luck and that you may be on your own, but who knows.

    Sorry, but I cannot help.

    ... but at least we have some information now
     
  8. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
  9. RG23

    Thread Starter Active Member

    Dec 6, 2010
    301
    2
    I configured a similar Newhaven OLED display before but it supported parallel interface and could write entire byte to portD and display data successfully.

    With this new display, there is only one serial data input line

    I still couldn't figure what changes need to be done to the command and data subroutines I used for the parallel interface

    or may be I am not approaching the issue correctly
     
  10. hexreader

    Active Member

    Apr 16, 2011
    249
    82
    That is not my reading of the datasheet, but maybe I am wrong.

    Still looks like SPI to me.
     
  11. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Your display uses a SPI interface, which is a standard way of moving serial data around a board, as opposed to say RS-232 which is expected to go between two remote device. There is lots of work on how to run these on the web.

    How you approach this may depend on which PIC you are using. If your PIC has a "Master Synchronous Serial Port module" or such then it has hardware built in to handle the transfer for you. If it does not either buy another device that does or look into making a bit-banged SPI interface.
     
  12. RG23

    Thread Starter Active Member

    Dec 6, 2010
    301
    2
    That is not my reading of the datasheet, but maybe I am wrong.

    Still looks like SPI to me.
    _____________________________________________________________

    You are right
    Just that
    In the parallel interface interface, I could use D0 to D7 at the same time

    Here I am limited to only one bit of PORTD
     
  13. hexreader

    Active Member

    Apr 16, 2011
    249
    82
    One bit of PORTD is not enough. You need at least two bits (clock and data) probably three, ideally 4.

    ... unless you want to add a second PIC into your design as an async serial to SPI driver?

    ... or change your LCD to an asynch serial one?
     
  14. GetDeviceInfo

    Senior Member

    Jun 7, 2009
    1,571
    230
    yes, there is only one data line, but there's a clock and a chip select. Why wouldn't you send your data to the SPI instead.
     
  15. RG23

    Thread Starter Active Member

    Dec 6, 2010
    301
    2
    Why wouldn't you send your data to the SPI instead.
    ______________________________________________________

    I am trying by that method

    but couldn't display the data

    Is there any example or any link that can be helpful?
     
  16. GetDeviceInfo

    Senior Member

    Jun 7, 2009
    1,571
    230
    how are you controlling the data/command line?
     
Loading...