-->
Page 1 of 2

Weak SPI output on Lolin NodeMCU V3

PostPosted: Wed Jun 22, 2016 1:20 am
by murray
I've been trying unsuccessfully to get a Lolin V3 NodeMCUs working with those 1.44 TFT displays you see on ebay, amazon and aliexpress. I'm using sumotoy's wonderful TFT_ILI9163C library. (https://github.com/sumotoy/TFT_ILI9163C/tree/Pre-Release-1.0p7) The documentation says:
"I've recently discovered that ESP8266 (NodeMCU 0.9 and NodeMCU 1.0 boards at list) has a weak SCLK output that vary from module to module, I really don't know why but voltage goes around 1.7 to 2.5 volt max. This should not be a problem for a SPI device but connecting more devices or some type of chip buffer can be problem! My 74HC125N for example do not work well. It's just a note ut I will investigate in future but please if you connect several SPI devices and not nothing work take count of this and do not apology!"

When I stumbled across this comment in the doc and decided to check it out with the scope. I disconnected the NodeMCU board from everything and took the attached traces of the SPI bus signals without anything connected.
    BLUE it the SPI clock (GPIO14 - HSCLK - D5)
    YELLOW is the SPI data line (GPIO13 - HMOSI - D7).
It's easier to see these scope traces on facebook (https://www.facebook.com/photo.php?fbid=10153733540570745&set=pcb.890150891114271&type=3&theater)

The SPI data line is a total mess, sometimes failing to even reach 1.3v while the SPI clock is typically 1.7v to 1.8v. The GPIO on the same chip delivers a crisp 3.3v as expected.

Suspecting bad hardware I tested with four different Lolin NodeMCU V3 boards and with multiple 2A power supplies and they're all the same. I added all kinds of capacitors to 5v and 3.3v, no change. I checked the schematic and beep tested the board to see where the SPI pins go, and they seem to be directly connected to the ESP module and nothing else as you would expect. Suspecting that the traces might be too thin, I tried it connected directly to the ESP12E module. No change. What do heck is going on here?

Re: Weak SPI output on Lolin NodeMCU V3

PostPosted: Wed Jun 22, 2016 1:41 am
by forlotto
Hrmmm.... Bad news that is the module I am currently using as well and had planned to order a touch screen hopefully there is some modification or something that could be done.

I do not recall in the thread for getting it to work via spi. Was there pullups etc did you need to set the frequency using the pwmfreq command?

That may aid you a bit possibly a frequency problem or an issue of needing more hardware to get it working correctly.

As pointed out pinD8 if it is used is being mapped to the wrong pin currently it should be mapped to pin 13 and it is mapped to pin 15 at the time of speaking so best bet is not to use the board numbers use the actual gpio numbers until this is figured out or fixed!

Dunno if I am going to help or waste your time with this one but hopefully not the later.

Good luck keep me updated on this one!

-forlotto

Re: Weak SPI output on Lolin NodeMCU V3

PostPosted: Thu Aug 04, 2016 1:46 pm
by sumotoy
This will be a long post, be warned!
1) I have to drop the max SPI frequency at 79.999999, at 80Mhz it's totally unstable and most of the times don't work!
2) The SPI CLOCK is WEAK, dot. Not only Lolin devices but I have several other devices here with the same problem (ESP7, ESP12, ESP12E...) differences are really tiny.

What drive me crazy is nobody talk about that (this is the first post I've seen!), cannot be that all modules I have (about 15) are all bad!
I discover this when I've tried to fix the RA8875 library for ESP8266, no matter what I do, should work but it doesn't. Connecting oscilloscope showed that SCLK dropped at 1V or less when connected to RA8875!!!
Measured with no load the SCK was around 1v3 to 2V max (in the best situation), can work but the ESP protection of most buffer I have here drop signal even more so at the end don't work.
I have tried different solutions, fet pullup not work since all these fet level converter have terrible performances (waveform distorted, positive offset etc.), buffers like 74HC125 or high speed ones don't help, level remain the same and in most case the original level is so low that buffer simply don't work.
Maybe a solution is use NL17SZ17 non inverter Schmitt trigger but working at high SPI frequency can be a serious problems due device limits and (most affecting) propagation delay so at the end is better apply a schmitt trigger to MOSI and MISO as well to have same timings.
Even worst, in the past, I've noticed that shmitt trigger from 74HC series add some voltage offset to low part of the signal, probably because the SPI clock is too fast for this series.
I have tried also the classic fet buffer but with a reference voltage on gate of 1.8V and a strong pullup on S pin for 3v3 volt, I got a decent voltage but waveform was horrible.
If someone has a serious solution I'm open to suggestions but remember that SPI speed can be very high for ESP and solutions like FET or the (terrible) adafruit/sparfun/chinese level converter, chip or fet are not the way to go.

The SPI frequency affect this?
Definetively yes, till 10Mz the level is almost right, at 40Mz it drops a lot and at 79.9Mhz is weak.

Why this has not been noticed before?
Many reasons, most libraries doesn't use SPI Transactions so it's not possible set the SPI frequency 'precisely', many libraries works at 8 or 16Mhz max!
Most SPI devices have high input impedance and accept low level of H/L threshold, things change when you connect more than one device or use relative low impedance devices (like RA8875 that also works in SPI MODE 3).

Why this happen?
Damn, I don't know! I spent hours around this, the problem is under the cover of ESP, maybe someone can illuminate.
I was thinking the SPI Flash affect the level but seems on other bus.

Should be normal?
I would say yes, but why the MOSI signal is never weak even if I force it to burst at the same freq of SCLK?
It doesn't look drop at any frequency...
So I say no, it's not normal, someone has to investigate soon or later!

Re: Weak SPI output on Lolin NodeMCU V3

PostPosted: Thu Aug 18, 2016 7:14 pm
by tcpipchip
I am having the same problem :(