XaLKiDEoS
Posts: 16
Joined: Thu Feb 14, 2013 9:29 am

320x240 LCD with integrated SSD1289 controller

Thu Feb 14, 2013 10:15 am

I am sure that many people are trying to make their Raspis to display video to a nonHDMI/nonCOmposite LCD screen using its SPI port, so I hope this thread will help all of us seeking expertise with the SSD1289 controller.

LCD Screens with SSD1289 controller sold in eBay for less than 10$. They include a touch screen film and an SD card reader. For the video, the screen needs 16pins for 16bits of data + 4-5 controll pins.
There are many arduino projects showing the screen connected to an arduino in action.

The problem with pi, is that its SPI does not offer that many GPIOs to "talk" to the screen using parallel mode. Although SSD1289 controller supports serial mode/interface, the LCD screen does not offer this capability. But this guy here: http://spritesmods.com/?art=spitft&page=1 made a nice schematic using a counter and 3 shift registers to get a parallel interface out of a serial. He also gives a kernel patch to enable the ssd1289 driver to use his hardware implementation but unfortunately he made it for Carambola linux platform. His patches include an ssd1289 driver he made from scratch, KConfig patch for adding his shift-registers hardware support to kernel and modifications to the SPI module of carambola.

I do not own a Carambola and I am trying to build the RaspberryPi's kernel using the patches Spritesmods.com provides after modifying them to match Raspberry's sources.

Carambola's patch includes patch for drivers/video/Kconfig and drivers/video/Makefile that I think can be applied easily to Raspi. Then the menuconfig will display an option to select native I/O or the shift registered hardware version.
Also the patch includes an ssd1289 driver that I placed in drivers/video/.

The difficult part here is to enable the ssd1289 driver from the SPI module (arch/arm/mach-bcm2708/bcm2708.c). I have made some attempts to make SPI "see" the ssd1289 without success.

I used kernel compilation on the Raspi (built once on a usb stick and execute make after each time to only build the changed file) Crosscompiling made the ssd1289 driver to throw a compilation error (I can't remember the error message).

I will post updates as soon as I have any news.

BR,

notro
Posts: 755
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: 320x240 LCD with integrated SSD1289 controller

Thu Feb 14, 2013 2:03 pm

I would like to help getting this display working on the PI (I don't have one my self).

I'm working on a LCD project of my own:
Source: https://github.com/notro/fbtft
Wiki: https://github.com/notro/fbtft/wiki

Here's my effort so far in making this patch build on the PI (building on the PI itself):

Wikipage on how to install kernel sources and to get make zinstall working

Apply patch

Code: Select all

cd
wget http://spritesmods.com/spitft/502-ssd1289-support-linux-3.3.8.diff
cd /usr/src/linux
patch -p1 < ~/502-ssd1289-support-linux-3.3.8.diff
Add debug output to drivers/video/ssd1289.c. So we know if probe() is called, that is, if the device is recognized (add before #includes).

Code: Select all

#define DEBUG
Kernel configuration

Code: Select all

make menuconfig
Device Drivers -> Graphics support -> Support for frame buffer devices -> [M] Solomon Systech SSD1289 controller support
SSD1289 LCD Controller Interface mode -> [X] LCD controller is connected over SPI using 4094/4020-ICs
Add SPI device to arch/arm/mach-bcm2708/bcm2708.c (32MHz is max on the PI, better start low)

Code: Select all

static struct spi_board_info bcm2708_spi_devices[] = {
	{
		.modalias = "spi-ssd1289",
		.max_speed_hz = 16000000,
		.bus_num = 0,
		.chip_select = 0,
		.mode = SPI_MODE_0,
	}, {
		.modalias = "spidev",
		.max_speed_hz = 500000,
		.bus_num = 0,
		.chip_select = 1,
		.mode = SPI_MODE_0,
	}
};
Build kernel

Code: Select all

# takes 8-9 hours on the first kernel build (locally), but minutes the next
time make 

WARNING: modpost: Found 1 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
This was a showstopper.

I'm now running: make CONFIG_DEBUG_SECTION_MISMATCH=y which will be finished in 8-9 hours, because it caused a full kernel rebuild.

Will post back when I know more.


(The reason for beeing so verbose, is that there is a lot of people reading these forums, including my self, and details is important to gain knowledge)

XaLKiDEoS
Posts: 16
Joined: Thu Feb 14, 2013 9:29 am

Re: 320x240 LCD with integrated SSD1289 controller

Thu Feb 14, 2013 2:24 pm

Hi notro,

very nice and helpful entry. I am still at work (16:18 GR time), I will try to post my work on bcm2708.c when I get home later today. What I remember is that only seting the driver name is not enough, I had added includes and defines for the GPIO pins (mosi, miso, reset) (I tried to understand what the Carambola SPI driver did and move the logic to Raspberry).

Just a tip for anyone reading this post. If you compile locally (not cross-compiling) and you spend 6-9 hours to get your first build, backup your build. I had a lot of corrupted filesystem errors and had to re-write my SD card making the kernel build to be lost. I find it easy to mount a usb stick and make the build ON the stick.

notro
Posts: 755
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: 320x240 LCD with integrated SSD1289 controller

Thu Feb 14, 2013 2:51 pm

I had added includes and defines for the GPIO pins (mosi, miso, reset) (I tried to understand what the Carambola SPI driver did and move the logic to Raspberry)
As I see it, this is not needed. The PI already has SPI available on the P1 header. And there is a SPI driver, but it has to be removed from the blacklist:
/etc/modprobe.d/raspi-blacklist.conf

Code: Select all

#blacklist spi-bcm2708
I had a lot of corrupted filesystem errors and had to re-write my SD card making the kernel build to be lost.
I also had one of those, well in my case case the card died :)

I missed something in my earlier post, for those trying to follow it:

Code: Select all

# Kernel configuration
# Use the running config
zcat /proc/config.gz > .config
make menuconfig

notro
Posts: 755
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: 320x240 LCD with integrated SSD1289 controller

Thu Feb 14, 2013 7:02 pm

I found the build problem, the patch was applied incorrectly

Have to strip 4 leading slashes in the directory names when applying patch
cd
wget http://spritesmods.com/spitft/502-ssd12 ... 3.3.8.diff
cd linux
patch -p4 < ~/502-ssd1289-support-linux-3.3.8.diff

notro
Posts: 755
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: 320x240 LCD with integrated SSD1289 controller

Fri Feb 15, 2013 4:16 pm

I finally got it working. The driver wouldn't unload when first loaded, so I had to add support for that and some other fixes.

Here's the code: http://pastebin.com/pkTf7xfJ

By working I mean loadning and unloading the driver without problems. I don't have a display to test with.

Code: Select all

fbset -i -fb /dev/fb1

mode "320x240"
    geometry 320 240 320 240 16
    timings 0 0 0 0 0 0 0
    rgba 5/11,6/5,5/0,0/0
endmode

Frame buffer device information:
    Name        : SSD1289
    Address     : 0xccd8c000
    Size        : 155648
    Type        : PACKED PIXELS
    Visual      : TRUECOLOR
    XPanStep    : 0
    YPanStep    : 0
    YWrapStep   : 0
    LineLength  : 640
    Accelerator : No

XaLKiDEoS
Posts: 16
Joined: Thu Feb 14, 2013 9:29 am

Re: 320x240 LCD with integrated SSD1289 controller

Tue Feb 19, 2013 9:28 am

notro your code definitely creates a new framebuffer for ssd1289.

I couldn't make the ssd driver built in the kernel, but only configured as a module. The module was loaded/ removed successfully however the screen did not came to life.

However, I connected 3 LEDs to MOSI, SCKL, CS0 of raspi set default framebuffer to dev/fb01 and tried to write something to it and the LEDs were blinking. I assume that commands are writen to SPI through the ssd1289 driver correctly.

My screen is slightly different than the one spritesmods uses. It does not provide a pinout diagram, it has the 40pin connector but does not for e.g. contains a BL_CNT as spritesmodes schema shows.

Anyway, I will try to debug the SPI and the schematic and will post when I have more news. I am trying to find a way to read the data sent from raspi's SPI to check if the commands for screen init and command data are correct.

notro, Nice work on the bcm2708.c :)

psgarcha92
Posts: 16
Joined: Fri Oct 12, 2012 5:19 am

Re: 320x240 LCD with integrated SSD1289 controller

Wed Feb 20, 2013 5:49 pm

Hey guys,

Would this screen work with a Raspberry pi? it is based on the above mentioned SSD1289 controller

http://www.ebay.com/itm/1pcs-3-2-inch-3 ... 3a779c0809

also it has a touchscreen...would that be a problem? i am looking forward to building a completely portable Raspberry Pi computer and have it with a minamal footprint that enables me to use it in my hands....

Regards

LesTroyer
Posts: 14
Joined: Wed Aug 29, 2012 2:38 pm

Re: 320x240 LCD with integrated SSD1289 controller

Wed Feb 20, 2013 10:40 pm

That looks like it would take 20+ data io lines for the screen portion - SPI is just for the touch screen...
You would not be able to drive that directly.

Les
psgarcha92 wrote:Hey guys,

Would this screen work with a Raspberry pi? it is based on the above mentioned SSD1289 controller

http://www.ebay.com/itm/1pcs-3-2-inch-3 ... 3a779c0809

also it has a touchscreen...would that be a problem? i am looking forward to building a completely portable Raspberry Pi computer and have it with a minamal footprint that enables me to use it in my hands....

Regards

XaLKiDEoS
Posts: 16
Joined: Thu Feb 14, 2013 9:29 am

Re: 320x240 LCD with integrated SSD1289 controller

Thu Feb 21, 2013 12:55 pm

As Les said this cannot be done directly but in this post we try to do this using 4 ICs (a counter and three registers) that would take serial input from raspberry's SPI and transforming to 24bits for the Screen. If you read my first post you will see another guy implemented that for another linux device the carambola.

LesTroyer wrote:That looks like it would take 20+ data io lines for the screen portion - SPI is just for the touch screen...
You would not be able to drive that directly.

Les
psgarcha92 wrote:Hey guys,

Would this screen work with a Raspberry pi? it is based on the above mentioned SSD1289 controller

http://www.ebay.com/itm/1pcs-3-2-inch-3 ... 3a779c0809

also it has a touchscreen...would that be a problem? i am looking forward to building a completely portable Raspberry Pi computer and have it with a minamal footprint that enables me to use it in my hands....

Regards

psgarcha92
Posts: 16
Joined: Fri Oct 12, 2012 5:19 am

Re: 320x240 LCD with integrated SSD1289 controller

Sun Feb 24, 2013 4:10 pm

@XaLKiDEoS

So basically the display i posted as the link would work, as it is almost identical to the spritesmods.com one right?? Have you been able to display anything on your display? and would the touch module also work fine with the Pi?

Am waiting for someone to get it working and then i would go buy it...

Regards

sghsmorgan
Posts: 27
Joined: Sun Jan 06, 2013 5:48 pm

Re: 320x240 LCD with integrated SSD1289 controller

Mon Feb 25, 2013 2:09 am

If you could get a way to get all of this working, that would be great!

valdodov
Posts: 19
Joined: Mon Feb 25, 2013 2:27 pm

Re: 320x240 LCD with integrated SSD1289 controller

Mon Feb 25, 2013 2:34 pm

Hi guys,

I think that there is a mistake in the electrical circuit.

CD4020 will count 32 cycles and then it will rise up its Q5. LCD's CS is active LOW, so i think that it will not work.

XaLKiDEoS
Posts: 16
Joined: Thu Feb 14, 2013 9:29 am

Re: 320x240 LCD with integrated SSD1289 controller

Tue Feb 26, 2013 7:41 am

Hi valdadov,
Thats correct, the driver sends 3bytes of display data and one dummy byte (32 bits/32cycles) then the strobe, CS is going high (inactive). But on the next cycle it goes low (active). So CS would remain low (active) for 32 cycles (1 display command). The 4094s keep their state after the strobe so the screen reads it while CS is low.

I tried to debug the circuit by counting the voltages of the ICs / and connected 20 LEDs on the ICs data pins and I figured out that the 4094s does not change state while on SPI0 (/dev/fb1). If I change the data input of the circuit to SPI2 (/dev/spidev0.1) - this can be done by simply moving the circuit's CS input from Raspberry's CS0 to CS1 on its SPI- and send random data, the CIs respond, and change state (LEDs turn on / off).

It looks like that Raspi's SPI resets the 4020 before it counts 32 cycles. It seems that an active low comes out of Raspi's CS on each cycle (which resets the counter).

valdodov wrote:Hi guys,

I think that there is a mistake in the electrical circuit.

CD4020 will count 32 cycles and then it will rise up its Q5. LCD's CS is active LOW, so i think that it will not work.

valdodov
Posts: 19
Joined: Mon Feb 25, 2013 2:27 pm

Re: 320x240 LCD with integrated SSD1289 controller

Tue Feb 26, 2013 9:18 am

Hi XaLKiDEoS,

when you connect the raspi to the power SPI /CS goes HIGH this causes reset of 4020 and its Q5 goes LOW. It is not correct situation for the LCD. You can't keep it's /CS LOW forever.

When you write 4 bytes to SPI it's /CS goes LOW then 4020 counts 32 cycles and its Q5 goes to HIGH then after some little time SPI's /CS goes HIGH and it causes reset of 4020 so Q5 goes LOW again.

I think that Q5 should be inverted and then applied to LCD.
The following pictures are after inversion of 4020s Q5

Image
Image
Last edited by valdodov on Fri Mar 29, 2013 5:58 am, edited 1 time in total.

XaLKiDEoS
Posts: 16
Joined: Thu Feb 14, 2013 9:29 am

Re: 320x240 LCD with integrated SSD1289 controller

Wed Feb 27, 2013 12:12 am

valdodov Hi,

I totally agree with you, the schematic would be correct if /CS was active (low) for the moment the data was feeded on the screen - as you said that can be done using a inverter for Q5.
I was just saying that spritesmod.com schematic should work too, please see the following scenario and correct me if I am wrong.
scenario 1 (without inverter) :
/CS starts high goes low
MOSI feeds the 4094s
SCLK increases the counter for 4020-4094
LCD-/CS is low (active) (not an LCD command on 4094s to read)
--- at the end of 4byte (clock 32 tick)
strobe goes high (4094s set their pins)
LCD-/CS goes high (inactive) nothing has been read from the LCD
--- after some ticks /CS goes high everything resets Q5 goes low LCD-/CS goes low (active)
(1) Now LCD reads the 4094s data already set on the previous ticks.
for the next 32 bits (clocks) the lcd will remain with /CS low as 4094 does not change state (strobe not high)

I am not sure if 4094 change its state when clock ticks after a strobe.
I wish I had an oscilloscope!!! By the way nice pics. Are they taken using real data from the ssd driver? Did you install the driver as this post explains and read these inputs? And if yes, why SPI is always low?
I am trying to understand if it is a hardware or software issue.

I didn't find any not gate at home I will buy a 7404 IC tomorrow to try the circuit with an inverted Q5.
As I didnt have an inverted I tried to make two raspi GPIO pins to simulate an inverter: (if PIN1==low PIN2 set HIGH else PIN2 set LOW) but it did not work either. I assume raspberrypi wiringpi is not fast enough to simulate a real NOT gate.

Anyway, I will try a real inverter tomorrow and will post any news.

Yiannis

valdodov
Posts: 19
Joined: Mon Feb 25, 2013 2:27 pm

Re: 320x240 LCD with integrated SSD1289 controller

Wed Feb 27, 2013 9:37 am

Hi XaLKiDEoS

actually with this buggy scenario (without inverting Q5) i succeed to see some drawing on the LCD.

The problem is with LCD Reset signal.
When SPI sends first 4 bytes Q5 remains HIGH for the next 4 bytes(32 cycles) and when 4094 shifts the third 4094 always resets LCD.

So my decision is to brake connection between third 4094s Q4 and LCD Reset and connect LCD Reset to +3.3V.

After that on the LCD appears some picture but it is strange.
I think my LCD is a little bit different than this in the example.
Image

I'm continuing with the investigations. :)
Last edited by valdodov on Fri Mar 29, 2013 6:02 am, edited 2 times in total.

XaLKiDEoS
Posts: 16
Joined: Thu Feb 14, 2013 9:29 am

Re: 320x240 LCD with integrated SSD1289 controller

Sat Mar 02, 2013 11:39 am

That's strange, even with your scenario I have not managed to get anything on the screen.
I am afraid that the person that sent me the screen from china (ebay) sent screen with other chip than SSD1289. The only thing that I managed to display on screen was a full pale blue colour.
Also my screen does not have any pinout printing on it, it contains 40 pins without a pinout table or something. I will try to find and buy the screen sprite modes uses.

pfff :(

Yiannis

Bluebox
Posts: 3
Joined: Tue Mar 05, 2013 2:44 pm

Re: 320x240 LCD with integrated SSD1289 controller

Tue Mar 05, 2013 2:50 pm

Any News? Has everyone a better circuit diagram, or can everyone make a better one?
Thanks

Durazell
Posts: 31
Joined: Sun Aug 12, 2012 3:50 pm
Location: Finland

Re: 320x240 LCD with integrated SSD1289 controller

Wed Mar 06, 2013 3:29 pm

This screen is based on SSD1289. If someone needs its schematics or other stuff i found this file in manufacturer's site:
https://dl.dropbox.com/u/36296754/HY32D.7z

sibaz
Posts: 3
Joined: Wed Feb 06, 2013 12:45 pm

Re: 320x240 LCD with integrated SSD1289 controller

Thu Mar 07, 2013 12:52 pm

I bought one of these: http://www.ebay.co.uk/itm/180819025871? ... 1439.l2649

And have nearly completed spritemod's circuit (I still need to solder up a separate 5v=>3.3v regulator to power the board)

I'm a tad concerned by the trouble you've all been having. Obvious question, but has anyone tried setting the SPI pins on the PI to GPIO mode, and driving them directly (clock included), thus slowing the whole cycle down, and watching what happens.

My intention is to attempt to write a script to send some dummy data, at a 1 second clock speed. It should prove if the circuit is working correctly, and assuming there is no minimum clock speed on the SSD1289, it should load data to it as intended. If you're right with the cs polarity being wrong, I'd have though it easy enough to prove by manually sending it the other way. Am I missing something?

valdodov
Posts: 19
Joined: Mon Feb 25, 2013 2:27 pm

Re: 320x240 LCD with integrated SSD1289 controller

Thu Mar 07, 2013 6:43 pm

Hi everyone,

finally I succeed !!!

Image

There are a few mistakes in SpritesMods's design and code.
1. You should remove connection between LCD's reset and third CD4094.
2. It is better to add one 74hc00 to reset CD4020 after each sent 32 bites. Tomorrow i'll give you the circuit.
3. In static int ssd1289_spi_write(struct ssd1289 *item, unsigned short value, unsigned int isdata) you should send 4 bytes not 3 like in the SpriteMods's patch.
4. In static void ssd1289_copy(struct ssd1289 *item, unsigned int index) you should use byte by byte sending not block sending. Tomorrow i'll investigate why it is not working with block sending.
5. You should lower the SPI speed to 8MHz.

Cheers
Last edited by valdodov on Fri Mar 29, 2013 5:59 am, edited 1 time in total.

XaLKiDEoS
Posts: 16
Joined: Thu Feb 14, 2013 9:29 am

Re: 320x240 LCD with integrated SSD1289 controller

Fri Mar 08, 2013 7:50 am

Congrats ! ! !
Finally we can see a clear nice image on the screen.
I have order a screen like the one you (and sprite mods) use as I suspect my screen is a bit different than yours. I will try your configuration when you upload your schematic with the old screen.

I will write when I have more news

Yiannis

Bluebox
Posts: 3
Joined: Tue Mar 05, 2013 2:44 pm

Re: 320x240 LCD with integrated SSD1289 controller

Fri Mar 08, 2013 11:30 am

@XaLKiDEoS What is the Problem with your Display?

XaLKiDEoS
Posts: 16
Joined: Thu Feb 14, 2013 9:29 am

Re: 320x240 LCD with integrated SSD1289 controller

Fri Mar 08, 2013 7:56 pm

@Bluebox
The screen I have is that one:
http://www.ebay.co.uk/itm/3-2-TFT-LCD-M ... 0631277050
It is a bit different than the one valdodov uses (it has 40 pins, incudes an SD card slot, etc). Also my screen does not have the pinout printed on the back. I tried to contact the guy from ebay so he may could send me / hep me with the pinout but without success. I assumed that the pinout would be the same as SSD1289 datasheet or the 40pins schematics I ve found on the internet.
Anyway, I think there is something wrong with my display because I haven't succeeded to display something on the screen, not even a corrupted desktop display as valdodov had on a previous post.

Return to “Other projects”