|
Hi,
honey the codewitch wrote: If I insert pauses between all my commands, my code will be the only code on the Internet that does that.
Are you sure about that? Look how the reference library you copied code from uses SPI_FREQUENCY[^] Also look at the busy-wait around the SPIBUSY[^] bits.
|
|
|
|
|
That's not an extra pause. That's just polling for the SPI transfer to complete, and my code does it too.
Here's how I write a byte:
*_spi_mosi_dlen = 7;
*_spi_w = value;
*_spi_cmd = SPI_USR;
while (*_spi_cmd & SPI_USR);
The only difference here is I'm referencing the registers via a volatile static member - but his code does that too - look at the different #ifdef paths. Also I'm using SPI_USR which is how you poll on an ESP32. I don't think you use the busy flag on this platform. not even sure it's defined. (he has different code files for different processors)
I use the frequency as well. It's a template argument to tft_spi<>
Real programmers use butterflies
|
|
|
|
|
Alright,
Well, I don't see anything else that stands out. You might need to figure this one out yourself. Unless you can find someone with similar hardware to take a look.
Best Wishes,
David Delaune
|
|
|
|
|
Yeah, that's where I'm at. I didn't figure on any help here, or I would have posted it in programming questions. I was just venting.
Real programmers use butterflies
|
|
|
|
|
Ok,
I thought I saw someone in the esp32 sub offer to test for you the other day. Maybe you should take up the offer.
|
|
|
|
|
Thanks. I must have missed it. I'll recheck my posts.
Real programmers use butterflies
|
|
|
|
|
I only bring this up because this post is so current (12/16/2021), succinct (18 minutes), and yet so comprehensive.
Xamarin.Forms Quickstart Deep Dive - Xamarin | Microsoft Docs
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
|
I appreciate things that are current, well written and relevant (IOS; Android; UWP; mobile). I gave my reason for posting it. What more do you need?
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
I used to. And hopefully I will again.
|
|
|
|
|
The Kinks, A Gallon Of Gas:
The Kinks - A Gallon Of Gas - YouTube[^]
[Edit]
I remember my first time in US before about 30 years. We joinend Los Angeles up to San Francisco with a camper. We payed sometething around $1 for one gallon. In my country we received 1L for that cash
Btw. 1 Gallon is about 3.79L
[Edit]
Currently US (google): $1 per Gallon$3.5 / Gallone
Here about: $2 per Liter
modified 18-Dec-21 15:12pm.
|
|
|
|
|
Yes and before
The less you need, the more you have.
Even a blind squirrel gets a nut...occasionally.
JaxCoder.com
|
|
|
|
|
|
The young ones over here only remember laughing gas
|
|
|
|
|
I remember gas at major chains being below a dollar a gallon. I also vaguely remember the last time I was at a gas station.
|
|
|
|
|
My first purchase of gas was .34/gal. when I bought my first car in 68.
The less you need, the more you have.
Even a blind squirrel gets a nut...occasionally.
JaxCoder.com
|
|
|
|
|
It is all relative. When I first started driving, gas was less than $0.20 a gallon. I remember disappointment when I no longer got 5 gallons for a dollar.
Gas wars in New Jersey brought it down to $0.11 a gallon at times.
Some stations gave green stamps or a water glass for a fill-up.
OTOH, most entry level jobs paid about $0.65 an hour (my first one paid less).
On the nostalgic side, when I was about 14 I visited my grand father in Canada. Had a cabin in the sticks. Post Office/general store/gas station had one of the old time pumps where you hand pumped the gas up into a jar (held 5 gallons) until you got what you wanted and then released into the tank. Probably imperial gallons, don't remember that far back. I have CRS (can't remember stuff).
>64
If you can keep your head while those about you are losing theirs, perhaps you don't understand the situation.
|
|
|
|
|
I remember gas in Canada being 49.9c/gallon in 1967. That's an imperial gallon (4.54 liters). I was 10 years old and had started to notice prices.
Today, gas is C$1.39/liter. But a silver 50c piece from 1967, the last year in which Canada issued silver coins, would still buy a gallon of gas, despite all the increases in gas taxes. The price of gas hasn't gone up. Instead, the currency has been debauched.
|
|
|
|
|
Greg Utas wrote: Instead, the currency has been debauched.
COVID: Hold my beer.
If you can't laugh at yourself - ask me and I will do it for you.
|
|
|
|
|
I remember gasoline for 42 cents a US gallon in 1969.
My friends in Texas said they paid only 25 cents at that time.
|
|
|
|
|
Don't want to give my age away, but I remember when gas was 30 cents per gallon.
Old men don't die. They just fade away...
|
|
|
|
|
Sorry, I'm not sure where to put this question, but I'd like opinions.
I have a graphics library, primarily targeting IoT devices. It has drivers for several displays.
The drivers could be faster, tbh. All of these drivers communicate over SPI (well there are I2C ones too but forget those for now). For those of you that don't know, SPI is a serial wire protocol that came about in like the 1980s or something. Your SD cards are SPI "slave devices"
I wrote a parallel driver for displays that support it. That means 8 data lines instead of one. It's not 8 times as fast, for hardware reasons, but it's much faster.
Anyway, I also refactored my new driver code so that it's layered, separating the concerns of driving the bus (either parallel or spi) and operating the specific display chip (like an ILI9341 or an ST7789)
The problem is this: I've optimized the SPI code in this new version and it only works on certain boards. There are timing issues. It's probably too fast, but I've had no luck getting it to work reliably. It only displays part of the tests, and then it freezes on most displays. As far as too fast, maybe the CS line control is too fast - it's not simply the SPI rate. I've tried changing that. For example, there's something called VDI rail that somehow needs more time to register a line change. I don't know more about it, it was just from sifting through Bodmer's code comments in TFT_eSPI, which I've been using as a guide.
So to recap, in the old code, it's all unoptimized SPI, but it works.
In the new code, there's also parallel support, and the unoptimized SPI works but the optimized SPI does not.
I *could* release it disabling the SPI optimizations, and keeping the parallel support and refactored code, but this release would have breaking changes - people would need to change existing code to use it.
I have no idea how long it will take me to fix the SPI. It vexes me.
My question is, should I release it, or should I wait until I can fix the SPI problems especially since it's a change that is disruptive to people's codebases?
Real programmers use butterflies
|
|
|
|
|
Very Crazy Stoned Idea: Is there a way to measure the SPI capabilities (e.g. at startup)? I mean, you write something onto the display and read it back (if possible) and compare that to what it should be. If it fails you lower the speed until it works...
|
|
|
|
|
It's not a matter of finding the right speed unfortunately. It's a matter of finding *where* it's too fast. I have no idea what needs to be slowed down. I've tried slowing down the CS line change and DC line changes, but no dice. It's bizarre. I'm not really sure what else to try. I've also tried disabling these particular optimizations by themselves:
inline static void write_raw8(uint8_t value) FORCE_INLINE {
#ifdef OPTIMIZE_ESP32
*_spi_mosi_dlen = 7;
*_spi_w = value;
*_spi_cmd = SPI_USR;
while (*_spi_cmd & SPI_USR);
#elif defined(OPTIMIZE_AVR)
SPDR=(C);
while (!(SPSR&_BV(SPIF)));
#else // !OPTIMIZE_ESP32
spi.transfer(value);
#endif // !OPTIMIZE_ESP32
}
When I do that, but I keep the optimized line changes, I get the same problem.
When I unoptimize the line changes, but keep this optimized, same problem.
Only when I unoptimize both does the problem go away.
The thing to remember, is this optimized code works on boards that are well constructed.
Real programmers use butterflies
|
|
|
|
|
Sorry maybe a naiv question. I don't get this part, what about value here:
#elif defined(OPTIMIZE_AVR)
SPDR=(C);
while (!(SPSR&_BV(SPIF)));
|
|
|
|