Hi,
I am able to drive a TFT display using SPI with 4 wires which are CS, CLK, MOSI, D/C. But recently, I am working on driving another TFT display using SPI with only CS, CLK, MOSI (without D/C pin). The trick is that I need to add once more bit in front of the 8 bits data/command I want to send. And that bit indicates whether the following 8 bits is command or not. Is it possible for esp32 to send 9 bit signal a time. What is the best way to implement it? Is there any limitation to that (i.e. cannot use dma)?
Please comment, thank you.
Thanks,
Jones
About Driving TFT with 3-wire SPI (no D/C pin, 9 bit data)
-
- Posts: 9772
- Joined: Thu Nov 26, 2015 4:08 am
Re: About Driving TFT with 3-wire SPI (no D/C pin, 9 bit data)
It's no different from other ways to control a SPI device, but you have to keep in mind that you need to pack the 9 bits of the data into the 8 bits you feed into the SPI peripheral. So for instance, a 3x9-bit transaction would have this data: dc 7 6 5 4 3 2 1 | 0 dc 7 6 5 4 3 2 | 1 0 dc 7 6 5 4 3 | 2 1 x x x x (Note that I'm not sure about the word or bit ordering, but you get the idea I hope.)
Re: About Driving TFT with 3-wire SPI (no D/C pin, 9 bit data)
Hi ngjones,
have you found a good way to perform this succesfully?
I am running into the same issue while trying to control an OLED display with 3-wire SPI.
Thanks a lot in advance,
- MZ
have you found a good way to perform this succesfully?
I am running into the same issue while trying to control an OLED display with 3-wire SPI.
Thanks a lot in advance,
- MZ
Re: About Driving TFT with 3-wire SPI (no D/C pin, 9 bit data)
Just in case someone else comes here:
I tried to follow @ESP_Sprite's suggestion and it worked great. I was afraid I had to toggle CS line after every 9 bits, but it appears it's not required as long as I keep CS low all the time.
Thank you @ESP_Sprite!
The way I've done it is by creating a buffer to write data into SPI. Using uint16_t is enough.
I append 9 bits on every write attempt and when my buffer length is over 8 bits, then I push those 8-bits into SPI.
I also had to add some dummy write of 0x00 at the end in case when I have less than 8 bits of data when everything is completed.
I tried to follow @ESP_Sprite's suggestion and it worked great. I was afraid I had to toggle CS line after every 9 bits, but it appears it's not required as long as I keep CS low all the time.
Thank you @ESP_Sprite!
The way I've done it is by creating a buffer to write data into SPI. Using uint16_t is enough.
I append 9 bits on every write attempt and when my buffer length is over 8 bits, then I push those 8-bits into SPI.
I also had to add some dummy write of 0x00 at the end in case when I have less than 8 bits of data when everything is completed.
Who is online
Users browsing this forum: Bing [Bot] and 94 guests