2009-02-22 03:09 AM
How to, 9bit SPI for a LCD
2011-05-17 03:52 AM
Hi,
Can someone help me to interface to a LCD that uses 9bit SPI for command and data transfer. My problem is how do I send the 9th bit out? Do I need to use 2 more pins attached to the SCK and MOSI, so I can clock out the 9th bit? Please help. Regards, Frank2011-05-17 03:52 AM
Googled SPI - confirmed that it is an ''interface'' NOT a protocol - so a 9 bit transfer should be legal. That said - most modern uCs - like the STM32 - support/provide just 8 or 16 bit transfers. (some ARM devices allow the selection of data size - but not Cortex M3)
SPI ''slave'' (your Lcd) likely requires a ''SPI-CS,'' ''SPI-CLK,'' & SPI-MOSI.'' (all reference to the STM32 master - check your Lcd data sheet) Massaging 9 bits is a kludge - but we have done it. Set up the STM32 for 16 bit tranfers - feed SPI-CLK to the Lcd through a 2K or so resistor - and tie the collector of an NPN xstr to the junction of 2K & Lcd's SPI-CLK input. In addition - feed SPI-CLK also to (ideally) the uC's timer/counter input. You count the 9 clocks - and disable the extra ones by using another STM32 output to turn on the NPN xstr - which ''kills'' the final 7 clock pulses @ the Lcd. I would ''slow'' the SPI speed during testing - gradually increasing after confirming correct operation. An alternative is bit-banging - uses just 2 or 3 uC outputs - but you must write the software routine to perform the 9 bit parallel to serial conversion.2011-05-17 03:52 AM
Hi Frank,
Many of the SPI slave chips, which use non-multiple-by-8 number of bits, have a compatibility with byte-oriented SPI hardware. In most of the cases it matters what are the last n-bits, which are received. Probably you could make it working by sending 16 bits and placing you data into the 9 least significant bits. Some other chips require that the usefull data is placed in the first bits, which are received. So, check which of both modes is relevant for you. Strobe the CS after the last byte is sent. Regards, Ivan2011-05-17 03:52 AM
Have you tried asking the LCD manufacturer and/or supplier?
They must, surely, be aware that many microcontroller (and other?) SPI masters have a fixed multiple-of-8 word size? Surely...? [ This message was edited by: st7 on 19-11-2008 14:05 ]2011-05-17 03:52 AM
Why must SPI master have a fixed multiple-of-8 word size?
Implementing a SPI master with configurable bitlength is very simple and I don't understand why STM used SPI IP with fixed word size. These LCDs have 9 bit SPI because 9th bit (or in this case 1st bit) is used instead of fixed address pin on the module and one pin is saved. I checked both NXP and EPSON datasheet and there is no information what will happen if one will send 16 bits instead of 9 (I'd bet on last in). Only test will show what will happen.2011-05-17 03:52 AM
I think I will try to send a 16bit thru the SPI an see if it works.
I seams more simplier. Thanks all for your help. Frank2011-05-17 03:52 AM
I made a test using the 16bit SPI configuration,
and shifting the 9bits << 7 so the MSB 9bit will go to the 16bit place. This allowed the lcd to be initialized, but not quite right... It looks like the controller does not like the following 7 bits sent thru the SPI. So it looks like that the only solution will be to kill the last 7 clocks as jj.sprague suggested, or someone else has an other idea to post!?The LCD in subject is the NOKIA 6610. Frank [ This message was edited by: jeepman on 19-11-2008 19:40 ] [ This message was edited by: jeepman on 19-11-2008 20:24 ]2011-05-17 03:52 AM
Experience is a harsh teacher - we tried & failed the simple first/last 9 bits suggested by others. (that's why we argued for the kludge) Of course we don't know which Lcd/controller you're using.
A simplification may result if you use a ''spld'' - you can use this to ''pass'' just your desired # of STM32 SPI clocks. *** Another thought - since you ''almost'' initialized - are you sure that the STM32 isn't ''too fast'' for your Lcd? Slow it & try again...[ This message was edited by: jj.sprague on 19-11-2008 20:33 ]2011-05-17 03:52 AM
I finally made it work using the 16bit spi and using in the MSB, the 9bits used.
It was a worng initiliazation sequence that I did wrong and it didn't work in the first place. So I can now confirm that this lcd controller ignores the rest 7 bits sent. Frank