New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better document that SPI speed is set with setSPISpeed after initR and not begin() #107
Comments
you could add a commented out line in an example |
As discussed adafruit#107 give users a clue how to change SPI speed
Sorry for the delay @ladyada , done in #114 That said, back to void Adafruit_ST77xx::begin(uint32_t freq) |
thanks for the PR! |
i think we could remove the argument, it is left over from a refactor |
@ladyada yep, looks like it. Are you ok removing it, or getting help from @makermelissa to remove it, or would you like me to send a PR? |
please send a PR, and we'll both take a look :) |
Guys, the way we have implemented that whole init process makes display unusable. Mine goes blank white because SPI starts @ 8 MHz and even I do set the frequency later it doesn't help. tft.setSPIFreqency(1000000); // set 1 MHz
tft.initR(); // init @ 1 MHz. |
Hello, I have a program that was working on STM32F103CBT6 (Arduino core STM32 support) with Adafruit GFX and ST775 libraries but not anymore with new versions. I am quite certain this is related to the SPI. Could you clarify how to set the SPI speed ? I am currently using
|
@mrguen |
@marcmerlin thanks |
Hello, my 1.8" TFT display runs fine on SW SPI with he AdafruitST7735 library on a UNO. So, I took my scope out, and connected it to the serial clock wire. As a first step, I would like to lower the HW SPI speed, and see if I can get it work. I have tried the suggestion mentioned in a post above:
But this doesn't work: the initialization fails!
This is exactly my situation: the screen simply goes blank... So the question is: how can I reduce the HW SPI speed while using the ST7735 library?? |
Update: given the information in the original post about what happens inside the libraries, I decided to do a hack. Despite this success however, the question as stated in my previous post remains !! |
Update 2: After considering how the "old" way of setting SPI speed is done using a clock divider of a power of 2, Perhaps things change when I would switch to another device, if that device can make other SPI clocks. So, given that in some systems the SPI bus wiring creates the speed bottleneck (my system may or may not be an example), I understand that the display library tries to make things simple for the Arduino user, So, given that the maximum SPI speed may be determined by more than just the display itself, |
First, I would recommend ditching the uno, it can do things, but it's so old and obsolete, while costing more than an ESP32 which is vastly superior in many ways. |
Hello Marc,
Many thanks for your advice and tips! Indeed, I have used the UNO with
great pleasure for a long time,
but I guess it is indeed time to start using something more advanced.
I think we agree that there is a good chance that the bus wiring determines
the maximum speed.
Unfortunately, this particular setup does not allow the wire length to be
shortened, or otherwise improved.
With the scope I do see significant under- and overshoot, so next I will
try clamping diodes as potential improvement.
The gfx library you suggested seems an interesting one. I need some time to
figure out how to tailor it
to my particular setup. Once I have it up and running, I will let you know!
Cheers,
Evert-Jan
…On Mon, Aug 1, 2022 at 2:05 AM Marc MERLIN ***@***.***> wrote:
First, I would recommend ditching the uno, it can do things, but it's so
old and obsolete, while costing more than an ESP32 which is vastly superior
in many ways.
That being said, I have had SPI displays that didn't work past 10Mhz or
so, and it was often due to my wiring, length, cross talk and quality of
wires. When I talked to the same display with the same chip on a circuit
board with proper copper traces, I was able to use 40 to 80Mhz.
Also, I recommend this TFT library, it's faster and has more options:
https://www.arduino.cc/reference/en/libraries/gfx-library-for-arduino/
—
Reply to this email directly, view it on GitHub
<#107 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A2JNRP2LZJ7INDMGFTPGMWLVW4IFZANCNFSM4KMLS3AQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Hello Marc,
I have tried the gfx library you suggested. After reading the wiki pages
for the bus and display invocations,
I tried to bring the HelloWorld example to life. The initial code I have
now looks as follows:
#include <Arduino_GFX_Library.h>
#define SPI_PIN_DC 7
#define SPI_PIN_CS GFX_NOT_DEFINED
#define GFX_PIN_RST 8
#define GFX_PIN_ROT 0
#define GFX_IPS false
#define GFX_WIDTH 128
#define GFX_HEIGHT 160
#define GFX_COL_OFS1 2
#define GFX_ROW_OFS1 1
#define GFX_COL_OFS2 2
#define GFX_ROW_OFS2 1
Arduino_DataBus *bus = new Arduino_HWSPI(SPI_PIN_DC,SPI_PIN_CS);
Arduino_GFX *gfx = new Arduino_ST7735(bus,GFX_PIN_RST,GFX_PIN_ROT,GFX_IPS,
GFX_WIDTH,GFX_HEIGHT,GFX_COL_OFS1,GFX_ROW_OFS1,GFX_COL_OFS2,GFX_ROW_OFS2);
The defines are as suggested by the wiki pages. (My display is a 7735
greentab.)
Changing the SPI speed is the same headache as with the AdaFruit library:
it is all built-in, the speed cannot be changed from user code.
So, I tried to hack it, similar to the AdaFruit case.
I have tried a few things, but nothing works: the screen stays stubbornly
blank.
Tomorrow, I will hook up my scope, to see what serial clock is present (if
any).
Cheers for now,
EJ
…On Thu, Aug 4, 2022 at 7:09 PM Evert-Jan Pol ***@***.***> wrote:
Hello Marc,
Many thanks for your advice and tips! Indeed, I have used the UNO with
great pleasure for a long time,
but I guess it is indeed time to start using something more advanced.
I think we agree that there is a good chance that the bus wiring
determines the maximum speed.
Unfortunately, this particular setup does not allow the wire length to be
shortened, or otherwise improved.
With the scope I do see significant under- and overshoot, so next I will
try clamping diodes as potential improvement.
The gfx library you suggested seems an interesting one. I need some time
to figure out how to tailor it
to my particular setup. Once I have it up and running, I will let you know!
Cheers,
Evert-Jan
On Mon, Aug 1, 2022 at 2:05 AM Marc MERLIN ***@***.***>
wrote:
> First, I would recommend ditching the uno, it can do things, but it's so
> old and obsolete, while costing more than an ESP32 which is vastly superior
> in many ways.
> That being said, I have had SPI displays that didn't work past 10Mhz or
> so, and it was often due to my wiring, length, cross talk and quality of
> wires. When I talked to the same display with the same chip on a circuit
> board with proper copper traces, I was able to use 40 to 80Mhz.
> Also, I recommend this TFT library, it's faster and has more options:
> https://www.arduino.cc/reference/en/libraries/gfx-library-for-arduino/
>
> —
> Reply to this email directly, view it on GitHub
> <#107 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/A2JNRP2LZJ7INDMGFTPGMWLVW4IFZANCNFSM4KMLS3AQ>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
|
update: In a flash of insight (Why didn't I think of this before?)
I tried to get the display to work with software SPI.
It still doesn't work, the display stays blank.
So I guess I must be doing something very wrong...
I will check the serial clock for both hardware and software SPI.
…On Fri, Aug 5, 2022 at 8:47 PM Evert-Jan Pol ***@***.***> wrote:
Hello Marc,
I have tried the gfx library you suggested. After reading the wiki pages
for the bus and display invocations,
I tried to bring the HelloWorld example to life. The initial code I have
now looks as follows:
#include <Arduino_GFX_Library.h>
#define SPI_PIN_DC 7
#define SPI_PIN_CS GFX_NOT_DEFINED
#define GFX_PIN_RST 8
#define GFX_PIN_ROT 0
#define GFX_IPS false
#define GFX_WIDTH 128
#define GFX_HEIGHT 160
#define GFX_COL_OFS1 2
#define GFX_ROW_OFS1 1
#define GFX_COL_OFS2 2
#define GFX_ROW_OFS2 1
Arduino_DataBus *bus = new Arduino_HWSPI(SPI_PIN_DC,SPI_PIN_CS);
Arduino_GFX *gfx = new Arduino_ST7735(bus,GFX_PIN_RST,GFX_PIN_ROT,GFX_IPS,
GFX_WIDTH,GFX_HEIGHT,GFX_COL_OFS1,GFX_ROW_OFS1,GFX_COL_OFS2,GFX_ROW_OFS2);
The defines are as suggested by the wiki pages. (My display is a 7735
greentab.)
Changing the SPI speed is the same headache as with the AdaFruit library:
it is all built-in, the speed cannot be changed from user code.
So, I tried to hack it, similar to the AdaFruit case.
I have tried a few things, but nothing works: the screen stays stubbornly
blank.
Tomorrow, I will hook up my scope, to see what serial clock is present (if
any).
Cheers for now,
EJ
On Thu, Aug 4, 2022 at 7:09 PM Evert-Jan Pol ***@***.***> wrote:
> Hello Marc,
>
> Many thanks for your advice and tips! Indeed, I have used the UNO with
> great pleasure for a long time,
> but I guess it is indeed time to start using something more advanced.
>
> I think we agree that there is a good chance that the bus wiring
> determines the maximum speed.
> Unfortunately, this particular setup does not allow the wire length to be
> shortened, or otherwise improved.
> With the scope I do see significant under- and overshoot, so next I will
> try clamping diodes as potential improvement.
>
> The gfx library you suggested seems an interesting one. I need some time
> to figure out how to tailor it
> to my particular setup. Once I have it up and running, I will let you
> know!
>
> Cheers,
>
> Evert-Jan
>
> On Mon, Aug 1, 2022 at 2:05 AM Marc MERLIN ***@***.***>
> wrote:
>
>> First, I would recommend ditching the uno, it can do things, but it's so
>> old and obsolete, while costing more than an ESP32 which is vastly superior
>> in many ways.
>> That being said, I have had SPI displays that didn't work past 10Mhz or
>> so, and it was often due to my wiring, length, cross talk and quality of
>> wires. When I talked to the same display with the same chip on a circuit
>> board with proper copper traces, I was able to use 40 to 80Mhz.
>> Also, I recommend this TFT library, it's faster and has more options:
>> https://www.arduino.cc/reference/en/libraries/gfx-library-for-arduino/
>>
>> —
>> Reply to this email directly, view it on GitHub
>> <#107 (comment)>,
>> or unsubscribe
>> <https://github.com/notifications/unsubscribe-auth/A2JNRP2LZJ7INDMGFTPGMWLVW4IFZANCNFSM4KMLS3AQ>
>> .
>> You are receiving this because you commented.Message ID:
>> ***@***.***>
>>
>
|
udate2: SWSPI is working now. I made the changes in HelloWorld anew,
and this time it worked, and it works reliably. So I suspect I made some
mistake
in my code yesterday.
HWSPI is still refusing coperation, though...
I opened an issue on Github, simply asking how I can set a custom SPI speed
from user code.
Let's see what the library developer (librarian?) suggests!
…On Fri, Aug 5, 2022 at 8:57 PM Evert-Jan Pol ***@***.***> wrote:
update: In a flash of insight (Why didn't I think of this before?)
I tried to get the display to work with software SPI.
It still doesn't work, the display stays blank.
So I guess I must be doing something very wrong...
I will check the serial clock for both hardware and software SPI.
On Fri, Aug 5, 2022 at 8:47 PM Evert-Jan Pol ***@***.***> wrote:
> Hello Marc,
>
> I have tried the gfx library you suggested. After reading the wiki pages
> for the bus and display invocations,
> I tried to bring the HelloWorld example to life. The initial code I have
> now looks as follows:
>
> #include <Arduino_GFX_Library.h>
>
> #define SPI_PIN_DC 7
> #define SPI_PIN_CS GFX_NOT_DEFINED
>
> #define GFX_PIN_RST 8
> #define GFX_PIN_ROT 0
> #define GFX_IPS false
> #define GFX_WIDTH 128
> #define GFX_HEIGHT 160
> #define GFX_COL_OFS1 2
> #define GFX_ROW_OFS1 1
> #define GFX_COL_OFS2 2
> #define GFX_ROW_OFS2 1
>
> Arduino_DataBus *bus = new Arduino_HWSPI(SPI_PIN_DC,SPI_PIN_CS);
>
> Arduino_GFX *gfx = new Arduino_ST7735(bus,GFX_PIN_RST,GFX_PIN_ROT,GFX_IPS,
>
> GFX_WIDTH,GFX_HEIGHT,GFX_COL_OFS1,GFX_ROW_OFS1,GFX_COL_OFS2,GFX_ROW_OFS2);
>
> The defines are as suggested by the wiki pages. (My display is a 7735
> greentab.)
>
> Changing the SPI speed is the same headache as with the AdaFruit library:
> it is all built-in, the speed cannot be changed from user code.
> So, I tried to hack it, similar to the AdaFruit case.
>
> I have tried a few things, but nothing works: the screen stays stubbornly
> blank.
> Tomorrow, I will hook up my scope, to see what serial clock is present
> (if any).
>
> Cheers for now,
>
> EJ
>
>
>
> On Thu, Aug 4, 2022 at 7:09 PM Evert-Jan Pol ***@***.***> wrote:
>
>> Hello Marc,
>>
>> Many thanks for your advice and tips! Indeed, I have used the UNO with
>> great pleasure for a long time,
>> but I guess it is indeed time to start using something more advanced.
>>
>> I think we agree that there is a good chance that the bus wiring
>> determines the maximum speed.
>> Unfortunately, this particular setup does not allow the wire length to
>> be shortened, or otherwise improved.
>> With the scope I do see significant under- and overshoot, so next I will
>> try clamping diodes as potential improvement.
>>
>> The gfx library you suggested seems an interesting one. I need some time
>> to figure out how to tailor it
>> to my particular setup. Once I have it up and running, I will let you
>> know!
>>
>> Cheers,
>>
>> Evert-Jan
>>
>> On Mon, Aug 1, 2022 at 2:05 AM Marc MERLIN ***@***.***>
>> wrote:
>>
>>> First, I would recommend ditching the uno, it can do things, but it's
>>> so old and obsolete, while costing more than an ESP32 which is vastly
>>> superior in many ways.
>>> That being said, I have had SPI displays that didn't work past 10Mhz or
>>> so, and it was often due to my wiring, length, cross talk and quality of
>>> wires. When I talked to the same display with the same chip on a circuit
>>> board with proper copper traces, I was able to use 40 to 80Mhz.
>>> Also, I recommend this TFT library, it's faster and has more options:
>>> https://www.arduino.cc/reference/en/libraries/gfx-library-for-arduino/
>>>
>>> —
>>> Reply to this email directly, view it on GitHub
>>> <#107 (comment)>,
>>> or unsubscribe
>>> <https://github.com/notifications/unsubscribe-auth/A2JNRP2LZJ7INDMGFTPGMWLVW4IFZANCNFSM4KMLS3AQ>
>>> .
>>> You are receiving this because you commented.Message ID:
>>> ***@***.***>
>>>
>>
|
Hello Marc,
Hmmmm.... the gfx lib that you recommended does not work with HWSPI, even
with a lower speed setting.
I opened a second issue on the forum (
moononournation/Arduino_GFX#190)
but reading the one-line responses I get the the feeling that the author
does not know about hardware much,
or at least that there is little interest to dive into the issue.
The remarkable thing is that HWSPI does work with the Adafruit library
(hacked for lower speed).
That tells me it is a software problem, as the hardware seems to be ok.
I tried a few things hacking into the Arduino_GFX library (fixing the SPI
speed, issuing a reset),
but no luck so far.
Anyway, I think I will stick with the Adafruit library for now!
Or perhaps you have another suggestion for me?
Cheers for now,
Evert-Jan
…On Sat, Aug 6, 2022 at 1:57 PM Evert-Jan Pol ***@***.***> wrote:
udate2: SWSPI is working now. I made the changes in HelloWorld anew,
and this time it worked, and it works reliably. So I suspect I made some
mistake
in my code yesterday.
HWSPI is still refusing coperation, though...
I opened an issue on Github, simply asking how I can set a custom SPI
speed from user code.
Let's see what the library developer (librarian?) suggests!
On Fri, Aug 5, 2022 at 8:57 PM Evert-Jan Pol ***@***.***> wrote:
> update: In a flash of insight (Why didn't I think of this before?)
> I tried to get the display to work with software SPI.
>
> It still doesn't work, the display stays blank.
> So I guess I must be doing something very wrong...
>
> I will check the serial clock for both hardware and software SPI.
>
> On Fri, Aug 5, 2022 at 8:47 PM Evert-Jan Pol ***@***.***> wrote:
>
>> Hello Marc,
>>
>> I have tried the gfx library you suggested. After reading the wiki pages
>> for the bus and display invocations,
>> I tried to bring the HelloWorld example to life. The initial code I have
>> now looks as follows:
>>
>> #include <Arduino_GFX_Library.h>
>>
>> #define SPI_PIN_DC 7
>> #define SPI_PIN_CS GFX_NOT_DEFINED
>>
>> #define GFX_PIN_RST 8
>> #define GFX_PIN_ROT 0
>> #define GFX_IPS false
>> #define GFX_WIDTH 128
>> #define GFX_HEIGHT 160
>> #define GFX_COL_OFS1 2
>> #define GFX_ROW_OFS1 1
>> #define GFX_COL_OFS2 2
>> #define GFX_ROW_OFS2 1
>>
>> Arduino_DataBus *bus = new Arduino_HWSPI(SPI_PIN_DC,SPI_PIN_CS);
>>
>> Arduino_GFX *gfx = new
>> Arduino_ST7735(bus,GFX_PIN_RST,GFX_PIN_ROT,GFX_IPS,
>>
>> GFX_WIDTH,GFX_HEIGHT,GFX_COL_OFS1,GFX_ROW_OFS1,GFX_COL_OFS2,GFX_ROW_OFS2);
>>
>> The defines are as suggested by the wiki pages. (My display is a 7735
>> greentab.)
>>
>> Changing the SPI speed is the same headache as with the AdaFruit library:
>> it is all built-in, the speed cannot be changed from user code.
>> So, I tried to hack it, similar to the AdaFruit case.
>>
>> I have tried a few things, but nothing works: the screen stays
>> stubbornly blank.
>> Tomorrow, I will hook up my scope, to see what serial clock is present
>> (if any).
>>
>> Cheers for now,
>>
>> EJ
>>
>>
>>
>> On Thu, Aug 4, 2022 at 7:09 PM Evert-Jan Pol ***@***.***> wrote:
>>
>>> Hello Marc,
>>>
>>> Many thanks for your advice and tips! Indeed, I have used the UNO with
>>> great pleasure for a long time,
>>> but I guess it is indeed time to start using something more advanced.
>>>
>>> I think we agree that there is a good chance that the bus wiring
>>> determines the maximum speed.
>>> Unfortunately, this particular setup does not allow the wire length to
>>> be shortened, or otherwise improved.
>>> With the scope I do see significant under- and overshoot, so next I
>>> will try clamping diodes as potential improvement.
>>>
>>> The gfx library you suggested seems an interesting one. I need some
>>> time to figure out how to tailor it
>>> to my particular setup. Once I have it up and running, I will let you
>>> know!
>>>
>>> Cheers,
>>>
>>> Evert-Jan
>>>
>>> On Mon, Aug 1, 2022 at 2:05 AM Marc MERLIN ***@***.***>
>>> wrote:
>>>
>>>> First, I would recommend ditching the uno, it can do things, but it's
>>>> so old and obsolete, while costing more than an ESP32 which is vastly
>>>> superior in many ways.
>>>> That being said, I have had SPI displays that didn't work past 10Mhz
>>>> or so, and it was often due to my wiring, length, cross talk and quality of
>>>> wires. When I talked to the same display with the same chip on a circuit
>>>> board with proper copper traces, I was able to use 40 to 80Mhz.
>>>> Also, I recommend this TFT library, it's faster and has more options:
>>>> https://www.arduino.cc/reference/en/libraries/gfx-library-for-arduino/
>>>>
>>>> —
>>>> Reply to this email directly, view it on GitHub
>>>> <#107 (comment)>,
>>>> or unsubscribe
>>>> <https://github.com/notifications/unsubscribe-auth/A2JNRP2LZJ7INDMGFTPGMWLVW4IFZANCNFSM4KMLS3AQ>
>>>> .
>>>> You are receiving this because you commented.Message ID:
>>>> ***@***.***>
>>>>
>>>
|
thanks for trying. HWSPI can be tricky, it either works or doesn't. |
With other TFTs, you set speed withtft->begin(spispeed)
With ST77xx, begin() is protected in Adafruit_ST77xx.h, so you cannot call tft->begin(tft_spi_speed). The documentation in the .cpp file therefore seem unusable:
Then we have this which basically ensures you can't call begin with a different frequency.
As a result, The only way to change the SPI speed is to do
I'm not sure what's the best way to make this findable. Maybe put a hint in "void Adafruit_ST77xx::begin(uint32_t freq) {" ?
The text was updated successfully, but these errors were encountered: