Shop Learn P1 Docs P2 Docs Events
Interfacing to a SCL1602 SPI LCD — Parallax Forums

Interfacing to a SCL1602 SPI LCD

I need some code help on interfacing a SCL SPI 2 X 16 LCD to a basic Stamp 2. I know I am in the stone age but sometimes you use what you have. I am using the Shiftout command and have everything set up for SPI not 12C and can get some characters on the LCD. The characters cannot be generated by using "Hello" etc. but seem to be generated by bringing up characters codes in the CGRAM of the SCL1602 character generator. I found this out by experimentation by creating a variable N (from 0 to 255). I create a for next loop and send out SHIFTOUT 9,8,1,[N,N]. The pin 8=clk,pin 9 =data and pin 10 is set for CS, MSBFIRST=1.Sometimes random characters are displayed but I see A,C,E ,etc, every other letter is seen. I still can't figure out why I have to send 2 'N's, but that's how I got it to work.
I have looked up various pieces of data on the SCL1602 and the graphics chip HD 44780 but no luck there. It seems with Arduino and Propeller, there are libraries already setup to use the LCDOUT function but the Basic Stamp 2 has no such command. I would really like to get some advice on control codes to send via Shiftout, so I can control and send characters to the LCD. Some say it is pointless to use such out of date methods, but getting partially there, I do think there is a solution to the problem. Any help would be appreciated. Thanks in advance, Stampman51


  • Need more information, I found this unit: SC1602LC Manual.pdf.

    Is this what you have?


  • This is the manual for the parallel loading version.I am using the SPI enabled version. I cannot use the 12C as the Basic Stamp does not support it. Thanks just the same.

  • I seem to remember programming something like this. The 44780 is in 4 bit mode so I had to shift in 8 bits but only the upper 4 were used and the lower 4 were discarded or something like that.


  • I found this code which works with my LCD 1602 except I have i2c.

     * Write to the Expander interface that talks to LCD1602
     * 4 bits at a time
     * Map b0 = RS, b1 = RW, b2 = CS(EN), b3 = Backlight
    void LCD1602_Nible(int n)
        LCD1602_Write(n | backlight);
        LCD1602_Write(n | LCD1602_ENABLE | backlight);
        LCD1602_Write(n | backlight);
    void LCD1602_Send(int value, int mode)
        int i;
        i = value & 0xf0;
        LCD1602_Nible(i | mode);
        i = (value & 0x0f) << 4;
        LCD1602_Nible(i | mode);

    It looks like it takes a couple of transmits to make it work. First output the upper 4 bits and then the lower 4 bits to program the controller.
    It clocks the Enable pin in-between to set the data. Lower 4 bits are shown in the map comment. Bit 4 is the enable pin on the 1602. Upper
    four bits are the data lines to the 1602.


  • Thanks for the additional info mike. I still am limited to using SPI format and I'll try some additional coding to see if I can coax the beast to work. I did discover something in the literature about setting the SCL1602 for control or data as in characters. I also have to get a consistant format as to the sequence of data to be sent to the display. Ihave found out by trial and error that sending SHIFTOUT 9,8,1,[12,5], actually clears the display. A definite work in progress. John

  • SPI is fine. But the end results are the same. The code I have shows the format of the data that has to be send to the unit. Your lower or upper data may be different based on how it was connected, but you are still taking serial data and converting it to parallel data that is used by the 1602.


  • I tried all kinds of byte patterns but I have found some characters are showing up, others not. All alphanumerics are not displayed and consecutive numbers sent only output every 4th character. It seems I may be accessing the character rom doing the following code. Pin 8 =CLK,Pin 9=DATA. MSBFIRST=1. SHIFTOUT 9,8,1,[5,1], turns off screen(LED Backlight still on. The digit 5 seems to be the active number the 1 seems to be a dummy number but has to be used for some reason. I tried different numbers and the result is the same. The SHIFTOUT 9,8,1,[6,1], turns on the display. I found all theses codes by doing a for next loop from 0 to 255 and putting that as the data in the Shiftout instruction. To send a "D", [12,209,1]. a "H', [12,210,1] and a "L", [12,211,1].
    I have discovered all this by trial and error because if I follow all the data I have looked at, I get ziltch. I still haven't figured a way to display , "HELLO" as the display will not display anything. I am still trying to translate the code I have looked at and a simple command code (using SHIFTOUT) and also sending characters directly into the display(using SHIFTOUT).
    I see other processors using libraries to put out codes using LCDOUT commands but Basic Stamp 2 does not use this command. This is a very stumping problem and there is probably an answer but I haven't found it yet.

  • It would help to know what unit you have since very few of them have an SPI interface. Take a picture if nothing else.

    These are some of the codes I have for the 1602 module and not your SPI interface which at this point may be getting in the way.

    #define LCD1602_CLEAR 0x01
    #define LCD1602_HOME 0x02
    #define LCD1602_ENTRY 0x04
    #define LCD1602_DISPLAY 0x08
    #define LCD1602_SHIFT 0x10
    #define LCD1602_FUNCTION 0x20
    #define LCD1602_CGADDRESS 0x40
    #define LCD1602_DDADDRESS 0x80

    There should be a pin for command/data and a pin for chip select. This tells the 1602 that you want to send data or commands.


  • I got my LCD from Jameco and it is a SCL1602N_BLWIT, White letters on blue background. Here is the pin out:

    Pin 1 Vss GND
    PIn 2 Vdd +V 3.3 or 5.0 v
    Pin 3 CS L=3 Line interface,H= 12C
    Pin 4 PSB H=12C, L=3 Line interface
    Pin 5 SCLK serial Clk
    Pin 6 SDA serial Data

    I noticed on the spec sheets for the HD44780 that with a parallel input LCD there is a register set pin R/S that selects whether Data is being sent as commands or Character data. There is no pin on this LCD and that is my problem. I need to know the correct SPI formatted code to allow the sending of commands or characters. There is probably one little subtle thing I am not seeing here.

  • Whooh,

    This is not a 1602, but 1602 look alike. They are using an aip31068 to drive this baby. Skip the interface board this got a whole lot simpler.

    Hold on to your hat for this one.

    You need to hold PSB low all the time for SPI.

    Then you need to hold CS low and send 9 bits of data and then release CS.

    Where is RS do you say, there isn't one. The first bit sent of the 9 is the RS value. Low is command, and High is data.

    Attached is the manual I found.


  • Stampman51Stampman51 Posts: 7
    edited 2022-03-04 21:27


    Thanks a lot for the new data, I don't know if I get to it today but this may work. Have to go thru some figuring on whether it is MSBFIRST or LSBFIRST but this may be the winner, thanks .


  • Stampman51Stampman51 Posts: 7
    edited 2022-03-07 11:17


    That last dat you sent me solved almost all of my problems. I was able to send control codes as well as data . There are some minor issues to be worked out as, I can't send letters in "Hello" format but in hexadecimal or decimal numbers.

    Example, to send an "A" , SHIFTOUT 9,8,1,[$141\9]/ The 9 represents 9 bits and the one preceding 41 is the code for data not a command. No wonder libraries are set up with the LCDOUT command as this AIP31068, does have it's own personallity. I also can't clear the display using 1, i.e. SHIFTOUT 9,8,1,[$0FE\9,$001\9], as it seems to home the cursor but the letters are displayed behind blocks. I have to use my old code I was using when experimenting, it is SHIFTOUT 9,8,1,[20,1]. This actually clears the display. This stuff can drive you bonkers, if you don't have complete data to go go. Once again, thanks for the info and it's a work in progress.
    There also seems to be no command like in the HD44780, to shift the cusor to the next row, puzzling to say the least. One of these days I'm going to write a book on keeping things simple, that's another subject.


Sign In or Register to comment.