Home > ARM > 320×240 Color Display – SSD2119

320×240 Color Display – SSD2119

January 27th, 2010 Leave a comment Go to comments

I finally got the display I bought on eBay to work. It took me a lot of hours as the man I’d bought the display from told me that the display controller was an ILI9320, so I started making code for the display like it was using an ILI9320 controller.

But as it didn’t work, I started debugging using my Raisonance RLink, and just when I looked at the Device variable – a variable which holds the controller number, and is loaded at the initialization process of the display, it showed me that it was an SSD2119 controller.

So I found the SSD2119 datasheet and started recoding using the new Command calls found in the datasheet… Finally it worked and showed some life 🙂

So right now I have a working SSD2119 code with SetPixel, Text, Circle, Rectangle, Fill and some working Touch Screen commands for the onboard ADS7843 touch screen controller.

Please take a look at this image to see the display in action:

SSD2119 seen from top

SSD2119 from top


SSD2119 Pringles example

The current GUI commands I’ve made is:
void Lcd_Text(u16 x, u16 y, u8 *str, u16 len,u16 Color, u16 bkColor);
void Lcd_Line(u16 x0, u16 y0, u16 x1, u16 y1,u16 color);
void Lcd_Circle(u16 cx,u16 cy,u16 r,u16 color,u8 fill);
void Lcd_Rectangle(u16 x0, u16 y0, u16 x1, u16 y1,u16 color,u8 fill); // Slower than Lcd_ColorBox
void Lcd_Square(u16 x0, u16 y0, u16 width, u16 color,u8 fill);
void Lcd_ClearCharBox(u16 x,u16 y,u16 color);
void Get320240PictureCode(u8* pBuffer,u32 BufferCounter,u32 BaseAddr);

void Lcd_FastRectangle(u16 x0, u16 y0, u16 x1, u16 y1,u16 color,u8 fill); // Faster than Lcd_Rectangle
void Lcd_FastSquare(u16 x0, u16 y0, u16 width, u16 color,u8 fill); // Faster than Lcd_Rectangle
void Lcd_FastClearCharBox(u16 x,u16 y,u16 color);

void DispPic320_240(const unsigned char *str);
void DispPic(u16 x0, u16 y0, const unsigned char *str);

DispPic320_240 and DispPic uses a byte array to show a image – the byte array is converted from a 24-bit .BMP (bitmap) file using a program I’ve made in Visual Basic .NET!

You can download the STM32 code for a Paint Demo application I’ve made here: SSD2119_PaintDemo
OBS.: The project files in there is for Ride7, but the code can be used together with ARM-GCC

Categories: ARM Tags: , , ,
  1. Frank
    January 30th, 2010 at 17:22 | #1

    Hi Thomas,

    I have the same LCD, and I have it all working but I am have a bit of a problem when displaying a picture.

    Can you please help me on this?
    What routine are you using to display the picture?

    Thanks
    Frank

    • January 30th, 2010 at 17:37 | #2

      Hi Frank.
      Have you made your own library? If not, which library are you using?

      I’m using a mixed library – I’ve mixed something from the uC/OS LCD library and something from ST’s LCD library.
      This included the Pixel, Circle, Text, Square commands – and then I made my own picture display command!

      First I save the image file on my computer as a 24-bit BMP.
      Next I use a program I made in VB.NET to convert the BMP to a header file.
      Last I include the header file in the project, and run the picture display command when needed.

      Best regards
      Thomas Jespersen

  2. Frank
    January 30th, 2010 at 19:16 | #3

    I am using the same library.
    I have using the following 2 programs to convert the image to .h

    http://www.thaieasyelec.net/archives/Manual/bmp2h_conv%20v5.1.rar
    http://www.thaieasyelec.net/archives/Manual/IMG2HEX.rar

    This is my DrawPicture routine:

    void LCD_DrawPicture(u16 StartX,u16 StartY,u16 EndX,u16 EndY,const unsigned short *pic) {

    u32 i;
    LCD_SetWindows(StartX,StartY,EndX,EndY);
    LCD_SetCursor(StartX,StartY);

    Clr_Cs;

    LCD_WriteIndex(0x0022);
    Set_Rs;
    for (i=0;i<(EndX*EndY) ;i++)
    {
    LCD_WriteData(*pic++);
    Clr_nWr;Set_nWr;
    }

    Set_Cs;
    }

    Can you please check and verify if the above are working?
    Best regards,
    Frank

    • January 30th, 2010 at 20:49 | #4

      It looks correct, but you can exclude the Set_Rs; just after the WriteIndex, as the WriteIndex sets the Rs pin high too!
      I’ve tried this code too, but the SetWindows command was the thing which was the problem for me!

      I’ve sent you an email with my DispPic code and my converter program – please try that and tell me if it works 🙂

  3. March 27th, 2010 at 07:22 | #5

    Hi Thomas ,,,

    See my development across SSD2119 & SPFD5420A in Crystalfontz forum ..

    SSD2119Z
    SPFD5420A

    http://www.crystalfontz.com/forum/showthread.php?t=6401
    http://www.crystalfontz.com/forum/showthread.php?t=6540

    Last night I also hacked Nokia E51 LCD 240×320 ,, I’ll shortly post my project ..

    Best Regards

    Imran

    • March 27th, 2010 at 10:40 | #6

      Very nice projects you’ve made – I hope sometime to be able to develop nice GUI’s like you, I just don’t have any ideas…

  4. March 27th, 2010 at 23:32 | #7

    Thomas Jespersen :
    Very nice projects youââ?¬â?¢ve made ââ?¬â?? I hope sometime to be able to develop nice GUIââ?¬â?¢s like you, I just donââ?¬â?¢t have any ideasââ?¬Â¦

    Hi thomas ,,,

    I’ve just hacked another Branded Cell Phone TFT ,, NOKIA E51 :):):)

    Visit my post on sparkfun … & if you wish then leave the comments their on sparkfun ..

    http://forum.sparkfun.com/viewtopic.php?f=14&t=20935

    thanks & Best Regards

    Imran

  5. Stevo
    April 5th, 2010 at 20:37 | #8

    Hi Thomas,

    nice job! Do you use the SPI interface of the display?

    Regards
    Stefan

    • April 5th, 2010 at 21:07 | #9

      No, I haven’t tried using the SPI interface to control the LCD!
      The problem with the SPI is also the speed. SPI is pretty slow when you have to transfer 16-bit color data to the whole screen = 2 bytes (16-bit) * 320 * 240 = 153600 bytes!
      So I’m using the 16-bit parallel interface instead, which means that I can send color data by clocking only once – of course I have to send some register adress settings first, which also requires some clock cycles, but it is much faster!

  6. Matteo
    April 11th, 2010 at 23:33 | #10

    I’m going to buy a TFT display but i don’t know the difference between ILI9320 SSD2119 this will be my first adventure about display.. so what ‘s the better!? i like your display based on SSD2119 but i don’t know nothing about it.. i found it on ebay and is cheaper than the 3,2 ” which you have just used .. i don’t find a library ready to use.. and I will not by something that maybe i’ll not able to use..tell me something XD i need some help..sorry i’m italian and my english is bad

    • April 12th, 2010 at 11:39 | #11

      Hi Matteo.
      The display I’m using is a 3.5″ display, and it was also found on eBay.
      I don’t know which controller to recommend, as they are much the same, also the controlling commands.
      As you can see on my blog I’ve tried using both, so I’ve made a library for both. So if you need a library, I have already made some – but if you want to, you could also make the yourself, just by looking at the datasheet!

      So I would recommend just buying the display you like (probably the cheapest) – as it doesn’t matter if it has an ILI9320, ILI9325 or SSD2119!

      Best Regards
      Thomas Jespersen

  7. Matteo
    April 12th, 2010 at 14:30 | #12

    I’ll need some help maybe.. XD but i want to try,yesterday i did a library of a rude controller..the KS108 but it was boring..too simple and I want to put myself to the test !!!!
    I like the 3.5″ cuz is bigger than another one i will buy it 🙂 but i don’t know if a simple PIC like PIC18F4620-I/P can store enough code lines in order to do some good projects.. it has got a PLL but the max clock will be 40 Mhz is it enough?!i need something else in order to control MMC touchpad !?so what are the peripherals i need?please give me some advice..

    Best Regards
    Matteo Dal Molin

    • April 12th, 2010 at 16:30 | #13

      Dear Matteo.
      The ILI9320 display I have I connected to an Arduino (8-bit – 16MHz), but also to an PIC18F452.
      This video is an example of what another guy have made with the same display as me (ILI9320) and a PIC18F458: http://www.youtube.com/watch?v=rRAn5ovDEmE
      The great thing is that both the ILI9320 is supported by Microchips Graphics Library, but be aware that not everything in that library will run on the PIC18’s.

      About Touch Screen, I don’t really know, as I haven’t tried it with the PIC or Arduino. I don’t think it would be any problem though, as it doesn’t takes much effort to read a touch screen variable (maybe even a digital touch screen controller).

      Best Regards
      Thomas Jespersen

  8. Matteo
    April 12th, 2010 at 16:45 | #14

    ok thank you! i hope that 40 Mhz will be enough to get a good refresh of the display so this week i’m going to buy 3.2 320×240 SSD2119…:):)

  9. Matteo
    April 12th, 2010 at 21:47 | #16

    OK! i’ve just see your project with dot matrix..i’ve been doing something like that but it is incomplete up to now ..it’s tetris game with 13×8 dot matrix..I can’t continue it cuz i promised to my friend that we will finish it together XD we have to do the last function which corporate the array of block and the game field and the counting of lines 🙂 enjoy your projects .. we will talk soon !

  10. Mariem
    April 22nd, 2010 at 10:19 | #17

    Hi Tomas,
    I’m runnig the demonstration software for the STM3210E-Eval.
    I displayed the main menu & the icons and now I need now to display some other icons according to my application to load them after that to the Internal Flash via DfuSe.
    Can you please help me with this ??
    Best Regards,

  11. Luca
    April 25th, 2010 at 22:42 | #18

    I bought the same LCD board on ebay, but I have some problem, I think that it is in init sequence…
    How do you set the setting register? (I don’t understand how set some value)

    Thank’s
    Luca

  12. Matteo
    July 13th, 2010 at 11:30 | #19

    Waaaa!The LCD 3.2 320Ã?240 SSD2119 has just arrived..but i have no time to try .. could you give me a library for pic?!So I can try it in my spare time..because i’m working and i’m hardly ever at home 🙁
    Best regards!

  13. July 13th, 2010 at 11:51 | #20

    @Matteo
    I haven’t got any SSD2119 library for the PIC, as Iâ??m using a mixed library.
    Iâ??ve mixed something from the uC/OS LCD library and something from STâ??s LCD library.

    You could try to download both things/libraries and then convert it for the PIC – it shouldn’t be that difficult, as the language is C, which is common for both C18 and Ride7 (GNU GCC)

    Best Regards
    Thomas Jespersen

  14. Matteo
    July 14th, 2010 at 21:50 | #21

    @Thomas Jespersen
    ok! this weekend I’ll try I saw your module based on a arm cortex M3 I’m interested about that so I found it on ebay..and maybe It’s one of the cheapest arm based system..Do you know other better solution!?I always work with pics but I understood for high speed ARM it’s better so i think that this module it’s suitable for beginners!so what do you think!?
    http://www.youtube.com/watch?v=dRggob7InTM This is the last school project made by me and others two friend..It’s quite rude but we had no time to improve the project and we had no money to buy quality components !

  15. Matteo
    July 15th, 2010 at 17:44 | #22

    I need also a programmer/debugger what do you suggest to me!? I saw on ebay one like the yours and also this one
    http://cgi.ebay.it/Keil-ULINK2-ARM-USB-JTAG-ARM9-ARM7-Cortex-M3-Cortex-M0-/290453659671?cmd=ViewItem&pt=LH_DefaultDomain_0&hash=item43a0632017
    I know that the second it’s a clone.. What is the best solution?!Sorry but I know nothing about ARM 🙁

  16. BitWise
    July 17th, 2010 at 22:56 | #23

    I have the same display but I’m having trouble getting any images displayed. Could you mail me a copy of the initialisation code you use?

    Thanks

  17. July 29th, 2010 at 08:38 | #24

    @Matteo
    Nice robot project – I’ve never done anything like that yet 🙁

    Anyways I really love that breakout board with the STM32F103RET6, as it’s cheap and I can interface what I want to interface to it – I’m not struggling with a development board with only a couple of I/O lines broke out (though development boards can be easier to start with)

    About the programmer, I’ve got this one http://cgi.ebay.ca/Raisonance-RLink-R-Link-Programmer-ARM-ARM7-ARM9-STM32-/150456002965?cmd=ViewItem&pt=LH_DefaultDomain_2&hash=item2307e06995#ht_1972wt_911 for $15 as there was an auction that time. But that Keil ULINK2 is also very great, as it supports other ARM processors too – which the RLink doesn’t!
    But you don’t need any processor, you only need an RS232 port (USB->RS232 converter works too) to program the chip. But if you want to do debugging, then you have to buy a programmer/debugger like theese two.

    Best Regards
    Thomas Jespersen

  18. July 29th, 2010 at 08:42 | #25

    @BitWise
    Done 🙂

  19. July 29th, 2010 at 08:48 | #26

    @Mariem
    Sorry for the late response, your comment was lost in my Spam filter 🙂
    Unfortunately I havenâ??t tried the STM3210E-EVAL board, but Iâ??ve took a look at the code, and it looks pretty straight forward.
    But I donâ??t know exactly what you are trying to do and needs help with â?? could you please explain?

    Thomas

  20. ben nguyen
    August 1st, 2010 at 21:48 | #27

    I saw this lcd on ebay and it looks sweet, even has touchscreen capability!

    But the datasheet ( http://www.graphicsdriversource.com/APIManual.pdf ) looks pretty intimidating, although I bet there’s other controllers that make this look trivial!

    My dream would be to run it (parallel mode) with a low cost 16-bit micro like the msp430 . I ordered a launch pad (it’s in my budget!) but I don’t think the micros have enough i/o’s.

    My coding is a quite poor, so I’m looking for any ssd2119 code that I could use as a starting point and port it to the msp430. I couldn’t find the code mentioned in this post, so probably not available… does anyone know of an alternative?

    Thanks!
    Ben

  21. Matteo
    August 11th, 2010 at 23:15 | #28

    Last week I tried to drive the SSD2119 controller but I don’t understand the corrispondance of pinout label of the breakout board of ebay and the name in the datasheet..
    At the table in the chapter 8080 interface page 79th of the datasheet there are WR RD DC CS..but in the breakout are different ..19.CS it’s ok like in the data..also WR and RD are in the data..RS in the breakout is DC in the data? I used the code at the crystallfontz at http://www.crystalfontz.com/product/CFAF320240F-T-TS.html in the section files,Software Source – Demonstration Code (148KB) … but the display is still white!:( I converted this code for a 18f4550 which works at 48Mhz(CPU clock 12Mhz).. and I powered the display i connected only pins from 1 to 22 of breakout board.. Could you say me if I’m doing something of wrong??
    Thanks!
    Best regars

  22. Matteo
    August 11th, 2010 at 23:30 | #29

    oh my god maybe it’s the pin RESET,i have to put it on 3.3 Volts …ohhhh shit! LOL Tomorrow I’ll try!

  23. Matteo
    August 12th, 2010 at 08:50 | #30

    No it isn’t the PIN RESET

    This is my test code:

    #include
    // control line pins
    #define LCD_CD RC7
    #define LCD_WR RC6
    #define LCD_RD RC1
    #define LCD_CS RC0
    #define LCD_RES RC2

    // macros for control lines
    #define CLR_CD PORTC &= ~(1<<LCD_CD);
    #define SET_CD PORTC |= (1<<LCD_CD);

    #define CLR_CS PORTC &= ~(1<<LCD_CS);
    #define SET_CS PORTC |= (1<<LCD_CS);

    #define CLR_RESET PORTC &= ~(1<<LCD_RES);
    #define SET_RESET PORTC |= (1<<LCD_RES);

    #define CLR_WR PORTC &= ~(1 << LCD_WR);
    #define SET_WR PORTC |= (1 << LCD_WR);
    #define CLR_RD PORTC &= ~(1 << LCD_RD);
    #define SET_RD PORTC |= (1 <0;t1–)
    {asm(“nop”);}
    }
    /*************************************************/
    void write_command(unsigned int command)
    {
    CLR_CS;
    CLR_CD;
    SET_RD;
    SET_WR;

    PORTB=command;//BASSA
    PORTD=command>>8;//ALTA

    CLR_WR;
    SET_WR;
    SET_CS;
    }

    /*************************************************/
    void write_data(unsigned int data)
    {
    CLR_CS;
    SET_CD;
    SET_RD;
    SET_WR;

    PORTB=data;
    PORTD=data>>8;

    CLR_WR;
    SET_WR;
    SET_CS;
    }
    /*************************************************/
    void initialization()
    {
    SET_RD;
    SET_WR;
    SET_CS;
    SET_CD;
    PORTB=0x00;
    PORTD=0x00;

    CLR_RESET;
    delay(200);
    SET_RESET;
    delay(500);

    write_command(0x0028); // VCOM OTP
    write_data(0x0006); // Page 55-56 of SSD2119 datasheet

    write_command(0x0000); // start Oscillator
    write_data(0x0001); // Page 36 of SSD2119 datasheet

    write_command(0x0010); // Sleep mode
    write_data(0x0000); // Page 49 of SSD2119 datasheet

    write_command(0x0001); // Driver Output Control
    write_data(0x32EF); // Page 36-39 of SSD2119 datasheet

    write_command(0x0002); // LCD Driving Waveform Control
    write_data(0x0600); // Page 40-42 of SSD2119 datasheet

    write_command(0x0003); // Power Control 1
    write_data(0x6A38); // Page 43-44 of SSD2119 datasheet

    write_command(0x0011); // Entry Mode
    write_data(0x6870); // Page 50-52 of SSD2119 datasheet

    write_command(0X000F); // Gate Scan Position
    write_data(0x0000); // Page 49 of SSD2119 datasheet

    write_command(0X000B); // Frame Cycle Control
    write_data(0x5308); // Page 45 of SSD2119 datasheet

    write_command(0x000C); // Power Control 2
    write_data(0x0003); // Page 47 of SSD2119 datasheet

    write_command(0x000D); // Power Control 3
    write_data(0x000A); // Page 48 of SSD2119 datasheet

    write_command(0x000E); // Power Control 4
    write_data(0x2E00); // Page 48 of SSD2119 datasheet

    write_command(0x001E); // Power Control 5
    write_data(0x00BE); // Page 53 of SSD2119 datasheet

    write_command(0x0025); // Frame Frequency Control
    write_data(0x8000); // Page 53 of SSD2119 datasheet

    write_command(0x0026); // Analog setting
    write_data(0x7800); // Page 54 of SSD2119 datasheet

    write_command(0x004E); // Ram Address Set
    write_data(0x0000); // Page 58 of SSD2119 datasheet

    write_command(0x004F); // Ram Address Set
    write_data(0x0000); // Page 58 of SSD2119 datasheet

    write_command(0x0012); // Sleep mode
    write_data(0x08D9); // Page 49 of SSD2119 datasheet

    // Gamma Control (R30h to R3Bh) — Page 56 of SSD2119 datasheet
    write_command(0x0030);
    write_data(0x0000);

    write_command(0x0031);
    write_data(0x0104);

    write_command(0x0032);
    write_data(0x0100);

    write_command(0x0033);
    write_data(0x0305);

    write_command(0x0034);
    write_data(0x0505);

    write_command(0x0035);
    write_data(0x0305);

    write_command(0x0036);
    write_data(0x0707);

    write_command(0x0037);
    write_data(0x0300);

    write_command(0x003A);
    write_data(0x1200);

    write_command(0x003B);
    write_data(0x0800);

    write_command(0x0007); // Display Control
    write_data(0x0033); // Page 45 of SSD2119 datasheet

    delay(150);

    write_command(0x0022); // RAM data write/read
    }
    /*************************************************/
    void Display_Home()
    {
    write_command(0x004E); // RAM address set
    write_data(0x0000); // Page 58 of SSD2119 datasheet
    write_command(0x004F); // RAM address set
    write_data(0x0000); // Page 58 of SSD2119 datasheet

    write_command(0x0044); // Vertical RAM address position
    write_data(0xEF00); // Page 57 of SSD2119 datasheet
    write_command(0x0045); // Horizontal RAM address position
    write_data(0x0000); // Page 57 of SSD2119 datasheet
    write_command(0x0046); // Horizontal RAM address position
    write_data(0x013F); // Page 57 of SSD2119 datasheet

    write_command(0x0022); // RAM data write/read
    }

    void display_rgb(unsigned int data)
    {
    unsigned int i,j;
    Display_Home();
    for(i=0;i<320;i++)
    {
    for(j=0;j<240;j++)
    {
    write_data(data);
    }
    }
    }

    void LCD_test()
    {
    unsigned int i,j;
    Display_Home();

    for(i=0;i<320;i++)
    {
    for(j=0;j<240;j++)
    {
    write_data(BLUE);
    delay(200);
    write_data(GREEN);
    delay(200);
    write_data(CYAN);delay(200);
    write_data(RED);delay(200);
    write_data(MAGENTA);delay(200);
    write_data(YELLOW);delay(200);

    }
    }
    }

    int main()
    {
    USBEN=0;

    TRISB = 0x00; // low data port, all outputs BASSA
    TRISD = 0x00; // low data port, all outputs ALTA
    //CONTROLLO
    TRISC = 0x00; // all outputs

    uint8 retry = 0;

    //OSCCAL = 0x00; //in order to operate some low speed card the initialization should run at lowest speed

    delay(0xfff);

    // Initialize the display
    initialization();

    LCD_test();
    while(1){LCD_test();}
    }

  24. August 12th, 2010 at 09:11 | #31

    @Matteo
    Hi Matteo.
    I’ve checked your code, and it looks kind of messy to me. It doesn’t look all correct, so here you have my initialisation code and WriteReg command – which sends both register adress and the data to be put in that register!

    void Lcd_WriteReg(u16 index,u16 dat)
    {
    Clr_Cs;
    Clr_Rs;
    Lcd_WriteData(index);
    Clr_nWr;
    Set_nWr;
    Set_Rs;
    Lcd_WriteData(dat);
    Clr_nWr;
    Set_nWr;
    Set_Cs;
    }

    void Lcd_WriteData(u16 data)
    {
    GPIOB->ODR=((GPIOB->ODR&0x00ff)|(data< <8)); GPIOC->ODR=((GPIOC->ODR&0xff00)|(data>>8));
    }

    void Lcd_Reset()
    {
    Set_Rst;;
    Lcd_Delay(50000);
    Clr_Rst;
    Lcd_Delay(50000);
    Set_Rst;
    Lcd_Delay(50000);
    }

    void LCD_Init() {

    Set_Rst;
    Set_nWr;
    Set_Cs;
    Set_Rs;
    Set_nRd;
    Set_Rst;
    Lcd_Reset(); // Lcd_Reset

    Lcd_WriteReg(0x0000,0x0001);
    Lcd_Delay(10000); // 10 ms

    //*********POWER ON &RESET DISPLAY OFF
    Lcd_WriteReg(0x28,0x0006); // VCOM OTP – Page 55-56 of SSD2119 datasheet

    Lcd_WriteReg(0x00,0x0001); // start Oscillator – Page 36 of SSD2119 datasheet

    Lcd_WriteReg(0x10,0x0000); // Sleep mode – Page 49 of SSD2119 datasheet

    Lcd_WriteReg(0x01,0x72ef); // Driver Output Control – Page 36-39 of SSD2119 datasheet

    Lcd_WriteReg(0x02,0x0600); // LCD Driving Waveform Control – Page 40-42 of SSD2119 datasheet

    Lcd_WriteReg(0x03,0x6a38); // Power Control 1 – Page 43-44 of SSD2119 datasheet

    Lcd_WriteReg(0x11,0x6874); // Entry Mode – Page 50-52 of SSD2119 datasheet

    // RAM WRITE DATA MASK
    Lcd_WriteReg(0x0f,0x0000); // Gate Scan Position – Page 49 of SSD2119 datasheet
    // RAM WRITE DATA MASK
    Lcd_WriteReg(0x0b,0x5308); // Frame Cycle Control – Page 45 of SSD2119 datasheet

    Lcd_WriteReg(0x0c,0x0003); // Power Control 2 – Page 47 of SSD2119 datasheet

    Lcd_WriteReg(0x0d,0x000a); // Power Control 3 – Page 48 of SSD2119 datasheet

    Lcd_WriteReg(0x0e,0x2e00); // Power Control 4 – Page 48 of SSD2119 datasheet

    Lcd_WriteReg(0x1e,0x00be); // Power Control 5 – Page 53 of SSD2119 datasheet

    Lcd_WriteReg(0x25,0x8000); // Frame Frequency Control – Page 53 of SSD2119 datasheet

    Lcd_WriteReg(0x26,0x7800); // Analog setting – Page 54 of SSD2119 datasheet

    Lcd_WriteReg(0x4e,0x0000); // Ram Address Set – Page 58 of SSD2119 datasheet

    Lcd_WriteReg(0x4f,0x0000); // Ram Address Set – Page 58 of SSD2119 datasheet

    Lcd_WriteReg(0x12,0x08d9); // Sleep mode – Page 49 of SSD2119 datasheet

    // —————–Adjust the Gamma Curve—-//
    Lcd_WriteReg(0x30,0x0000); //0007

    Lcd_WriteReg(0x31,0x0104); //0203

    Lcd_WriteReg(0x32,0x0100); //0001

    Lcd_WriteReg(0x33,0x0305); //0007

    Lcd_WriteReg(0x34,0x0505); //0007

    Lcd_WriteReg(0x35,0x0305); //0407

    Lcd_WriteReg(0x36,0x0707); //0407

    Lcd_WriteReg(0x37,0x0300); //0607

    Lcd_WriteReg(0x3a,0x1200); //0106

    Lcd_WriteReg(0x3b,0x0800);

    Lcd_WriteReg(0x07,0x0033); // Display Control – Page 45 of SSD2119 datasheet
    }

  25. Matteo
    August 15th, 2010 at 14:26 | #32

    🙁 🙁 It’s still not working,I used your code and than I wrote this main:
    int main()
    {
    RBPU=1;//Internal pull-up disable
    TRISB = 0x00; // low data port, all outputs BASSA
    TRISD = 0x00;
    TRISC = 0x00; // all outputs

    // Initialize the display
    LCD_Init();
    delay(300);//300ms
    Lcd_WriteReg(0x0022,0x0000);

    while(1){
    Clr_nWr;
    Set_nWr;
    Set_Rs;
    Lcd_WriteData(0x0000);
    }
    }

    with this code the display should be black..but it’s still white 🙁

  26. Matteo
    August 18th, 2010 at 11:05 | #33

    The STM32 module it’s arrived..so i can understand if my code is wrong ..could you send me your pins configuration and the hex of your test code?!

  27. August 18th, 2010 at 12:38 | #34

    @Matteo
    My LCD_Clear command looks like this:
    void Lcd_Clear(u16 dat)
    {
    u32 i;

    Lcd_SetCursor(0x0000, 0x0000);
    Clr_Cs;
    Lcd_WriteIndex(0x0022);
    Set_Rs;
    Lcd_WriteData(dat); // Placed here for optimization: As we are putting the same color, we just need to set the color-bus once (as long it doesn’t change)
    for(i=0;i<76800;i++)
    {
    //Lcd_WriteData(dat); // Removed for optimization: This isn't needed here, as we are putting the same color, so just set it at the beginning of the loop
    Clr_nWr;
    Set_nWr;
    }

    Set_Cs;
    }

    And the LCD_SetCursor looks like this:
    void Lcd_SetCursor(u16 x,u16 y)
    {
    Lcd_WriteReg(0x004E,x);
    Lcd_WriteReg(0x004F,y);
    }

    And the LCD_WriteIndex looks like this - it's like the first part of WriteReg (telling which register to write to):
    void Lcd_WriteIndex(u16 idx)
    {
    Clr_Rs;
    Set_nRd;
    Lcd_WriteData(idx);
    Clr_nWr;
    Set_nWr;
    Set_Rs;
    }

  28. Phil
    September 5th, 2010 at 21:14 | #35

    Hi Thomas,

    please can you share you library ? a link ??
    i would like to use the same LCD with a 18F66J50 and have some trouble with the pixels mapping.

    thanks
    phil

  29. September 6th, 2010 at 17:57 | #36

    @Phil
    I’ve now uploaded a Paint Demo code which uses the display and the touch screen controller (ADS7843) – the download link is in the post!

  30. Richard
    September 20th, 2010 at 15:34 | #37

    Hi Thomas,

    really nice jobs.
    I’m trying to get a display (CFAF320240F with SSD2119) work with your demo code on a STM32F105VCT6. But only the backlight is working so far. I’m using another port configuration like you, but I can’t find an error.
    Maybe you’ll find something wrong in the following lines:

    #define Set_Cs GPIO_SetBits(GPIOD,GPIO_Pin_2);
    #define Clr_Cs GPIO_ResetBits(GPIOD,GPIO_Pin_2);

    #define Set_Rs GPIO_SetBits(GPIOD,GPIO_Pin_1);
    #define Clr_Rs GPIO_ResetBits(GPIOD,GPIO_Pin_1);

    #define Set_nWr GPIO_SetBits(GPIOD,GPIO_Pin_0);
    #define Clr_nWr GPIO_ResetBits(GPIOD,GPIO_Pin_0);

    #define Set_nRd GPIO_SetBits(GPIOD,GPIO_Pin_4);
    #define Clr_nRd GPIO_ResetBits(GPIOD,GPIO_Pin_4);

    #define Set_Rst GPIO_SetBits(GPIOD,GPIO_Pin_3);
    #define Clr_Rst GPIO_ResetBits(GPIOD,GPIO_Pin_3);

    #define Lcd_Light_ON GPIO_SetBits(GPIOD,GPIO_Pin_8);
    #define Lcd_Light_OFF GPIO_ResetBits(GPIOD,GPIO_Pin_8);

    #define nCsPin GPIO_Pin_2
    #define RsPin GPIO_Pin_1
    #define nWrPin GPIO_Pin_0
    #define nRdPin GPIO_Pin_4
    #define nRstPin GPIO_Pin_3
    #define Lcd_LightPin GPIO_Pin_8

    void Lcd_Configuration(void)
    {
    GPIO_InitTypeDef GPIO_InitStructure;

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOD, ENABLE);

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_Init(GPIOE, &GPIO_InitStructure);

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_8;
    GPIO_Init(GPIOD, &GPIO_InitStructure);
    Lcd_Light_ON;
    }

    void Lcd_WriteData(u16 data)
    {
    GPIOE->ODR = data;
    }

    __inline u16 Lcd_ReadData(void)
    {
    u16 tmp;
    GPIOE->CRH = (GPIOE->CRH & 0x00000000) | 0x44444444;
    GPIOE->CRL = (GPIOE->CRL & 0x00000000) | 0x44444444;
    tmp = (((GPIOE->IDR)>>8)|((GPIOE->IDR)<CRH = (GPIOE->CRH & 0x00000000) | 0x33333333;
    GPIOE->CRL = (GPIOE->CRL & 0x00000000) | 0x33333333;
    return tmp;
    }

    thanks
    richard

  31. September 21st, 2010 at 18:00 | #38

    @Richard
    Hi Richard.
    I’ve checked your code, and to me it doesn’t look wrong. I’m a bit unsure about the Lcd_ReadData, but unfortunately I’m not that good at the CRL and CRH commands.
    But how does your WriteReg look like?

  32. Chuck
    September 22nd, 2010 at 01:47 | #39

    Awesome project! The SSD2119 has a feature for smooth vertical scrolling, which I think would be great for something like a command-line console. Have you looked into that at all? The datasheet is vague on the details.

  33. September 29th, 2010 at 17:27 | #40

    @Chuck
    Thanks.
    No I haven’t looked into the scrolling feature on the SSD2119, I’ve only tried it on the SSD1963!

  34. September 5th, 2011 at 17:43 | #41

    Dette er mit første besøg igen, når jeg er her . Jeg fandt en masse interessante ting i din blog især dens diskussion. Med tonsvis af kommentarer på dine artikler , tror jeg jeg er ikke den eneste, der har det hele her! Fortsæt det gode arbejde .

  35. April 10th, 2013 at 18:10 | #43

    Once again Hello Thomas ..

    I need your help regarding the interfacing of MicroSD Card with ARM (LP2292 or STM32F407).
    In exchange , I can offer you my codes (if you are interested in any)

    kindly reply me by email.

    elect_design_eng@yahoo.com

    best regards

    Imran

  36. April 18th, 2013 at 21:17 | #44

    @s_black
    It simply hadn’t been accepted yet (spam filter integration).
    I acknowledge your work as it seems you have got a good understanding of the display and how to control the SSD2119 display controller.

    For others interested in controlled SSD2119 displays with LM3S9B9x microprocessors I would definitely recommend having a look at @s_black’s post.
    Regards Thomas

  37. April 18th, 2013 at 21:27 | #45

    @Imran
    We have been interfacing and using MikroSD cards a lot with the STM32F407. It is not very difficult to get working.

    I recommend you use the FatFS for the FAT driver.
    You can download my FatFS implementation for the STM32F4 here: FatFS_STM32F407.zip
    Please be aware that this implementation is made for use with the FreeRTOS but is easily changed to non-RTOS by changing only a couple of lines.

    Good luck.

    Kind regards
    Thomas Jespersen

  38. August 20th, 2013 at 15:27 | #46

    hi dear
    what is the interface of your code?
    6800 or 8080 parallel?

  39. August 20th, 2013 at 22:55 | #47

    @jafari
    We prefer to use 8080 parallel with the nRD and nWR signals.
    Regards Thomas

  40. dvf007
    July 12th, 2014 at 14:23 | #48

    Hi.
    I had problem with put x-coordinate to relevant registers – R4eh. It is possible to registers R48h, R4Ah too.
    ID reads like 0x9959 instead 0x9919.
    Interface: 8080 – 16 bit.
    🙁
    Previously SPI values have been right.
    P.S. ?ircuits have no errors.

  41. July 16th, 2014 at 05:20 | #49

    @dvf007
    If you say that the registers, especially the ID register, has rerturned the correct valued when connected thru SPI, I am quite sure that something is wrong with your connection.
    Have you confirmed that all data lines is correctly connected – also in the right order?
    Furthermore have you made sure that the controller mode points has been changed to enable the 8080 parallel mode rather than the SPI mode?
    Regards Thomas

  42. Hassan
    October 18th, 2014 at 08:37 | #50

    Hi, I was wondering if this display ( http://www.buydisplay.com/default/3-5-lcd-display-tft-module-320×240-serial-spi-touch-screen-arduio ) which also has SDD2119 controller will work with an Arduino Due via 4-wire SPI?

    I want to use 16.7M colors to load my interface.

  43. October 18th, 2014 at 19:50 | #51

    @Hassan
    Yes, you could theoretically control this display with 4-wire SPI but the update rate will be very slow – especially if you want 16.7M colors which is 24-bit. Instead I would recommend you to use the 16-bit parallal bus and reduce the colors to 16-bit (65.5K), as this will give you a much smoother refresh rate.

    Regards Thomas

  44. Miquel
    August 31st, 2016 at 21:40 | #52

    Hi Thomas

    Searching the net a program about touch screen controller ADS7843 I went to your page.
    Very interesting all publications!!.

    Well! I pass to tell you my problem.

    Three months ago I have one 3,5 TFT color LCD module 320×240 with SSD2119 and ADS7843.
    With the specifications of datasheet I have written a program,mode 16 bits,in assembler
    asm51 running on micro AT89S8253 perfectly;but I have a problem with the programming ads7843.

    I don’t know well the programming SPI-control register of microprocessors.

    Please, Can you tell me what must be values bits CPOL and CPHA ?.

    Thank you very much.
    Miquel

  45. September 16th, 2016 at 06:16 | #53

    @Miquel
    Sorry, such CPOL and CPHA configuration values are very specific to the processor, in this case the ATMEL ATSAM type.
    You would have to look up the data sheet or probably peripheral register-set reference sheet to find the correct values.
    Or for simple SPI communication as it is with the ADS7843 touch sensor you could also find existing examples on how to initiate SPI communication or you could write this yourself using simple bit-bang methods as fast data-speed is not needed.

  46. Miquel
    September 16th, 2016 at 21:27 | #54

    Hi Thomas:

    Very grateful for your information.
    I will do several tests and already inform you about it.

    Thank you very much.
    Miquel

  47. Miquel
    September 30th, 2016 at 18:35 | #55

    Hi Thomas:

    Exploring SPI protocol and with the help of a Logic Analyzer
    I managed properly program the bits CPOL and CPHA registry
    AT89S8253 control for the ADS7843 work properly.

    Regards Miquel

  1. No trackbacks yet.