-
Notifications
You must be signed in to change notification settings - Fork 62
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
ESP32 to SSD1331 HWSPI using correct default pin numbers? #8
Comments
Hardware SPI to OLED display is of course possible.
ESP32 shares SD card pins with FPGA. In my esp32 web-jtag
firmware, I use hardware SPI to both SD and OLED
with a small help of FPGA logic that routes it thru.
Only 1 additional esp32 gpio pin is used for chip select OLED.
So when you want to talk to OLED instead of SD card,
de-select SD_CSn=1, select OLED_CSn=0 and SPI traffic
will be received by OLED, SD will ignore it.
You can't use both SD and OLED at the same time, hopfully
ESP32 will not run linux anytime soon.
…On 6/6/19, gojimmypi ***@***.***> wrote:
I am unable to get the SSD-1331 display working in HWSPI (fast) mode. I'm
wondering if the SPI pins are connected the same as the default
ESP-Dev-Module (WROOM-32). I'm thinking perhaps not.
I was able to get the ESP32 to use the SSD-1331 display in SWSPI (slow)
mode. using these pin definitions and the passthru code loaded on the FPGA:
```
// ULX3S names in physical connector order:
#define oled_csn 17 // aka cs
#define oled_dc 16 // aka ds
#define oled_resn 25 // aka rst
#define oled_mosi 15 // aka mosi
#define oled_clk 14 // aka sclk
```
For the SWSPI, the `option 1` in the [Adafruit LCDGFXDemo
example](https://github.com/adafruit/Adafruit-SSD1331-OLED-Driver-Library-for-Arduino/blob/master/examples/LCDGFXDemo/LCDGFXDemo.ino#L36),
the display is instantiated like this:
```
// Option 1: use any pins but a little slower
#pragma message "Using SWSPI"
Adafruit_SSD1331 display = Adafruit_SSD1331(oled_csn, oled_dc, oled_mosi,
oled_clk, oled_resn);
```
For HWSPI, the display is instead instantiated like
[this](https://github.com/adafruit/Adafruit-SSD1331-OLED-Driver-Library-for-Arduino/blob/master/examples/LCDGFXDemo/LCDGFXDemo.ino#L40):
```
#pragma message "Using HWSPI"
Adafruit_SSD1331 display = Adafruit_SSD1331(&SPI, oled_csn, oled_dc,
oled_resn);
```
I have some addition notes in my [SSD1331 Branch of
Examples](https://github.com/gojimmypi/ulx3s-examples/tree/SSD1331/VisualMicro-SSD1331-Display#arduino-implmentation-notes)
and duplicated here:
## Arduino Implmentation Notes
This an Arduino-style solution, suitable for use with either the [Ardunio
IDE](https://www.arduino.cc/en/Main/Software),
or [Visual Micro](https://www.visualmicro.com/). The display can be
initialized either with this software SPI, which is
perhaps more flexible but a little slower:
```
Adafruit_SSD1331 display = Adafruit_SSD1331(cs, dc, mosi, sclk, rst);
```
... or the alternative is this hardware SPI instantiation (untested / not
working at this time):
```
Adafruit_SSD1331 display = Adafruit_SSD1331(&SPI, cs, dc, rst);
```
Note the [comments in the Adafruit
code](https://github.com/adafruit/Adafruit-SSD1331-OLED-Driver-Library-for-Arduino/blob/master/examples/LCDGFXDemo/LCDGFXDemo.ino#L29):
> hwspi hardcodes those pins, no need to redefine them.
**As the ULX3S appears to use different pins, is HWSPI even possible?** The
`cs`, `dc`, `rst` pins do not seem to be otherwise defined without the
macros.
The `&SPI` is defined in
`%USERPROFILE%\Documents\Arduino\hardware\espressif\esp32\libraries\SPI\src\SPI.cpp`
of interest, is this initialization code:
```
if(sck == -1 && miso == -1 && mosi == -1 && ss == -1) {
_sck = (_spi_num == VSPI) ? SCK : 14;
_miso = (_spi_num == VSPI) ? MISO : 12;
_mosi = (_spi_num == VSPI) ? MOSI : 13;
_ss = (_spi_num == VSPI) ? SS : 15;
} else {
_sck = sck;
_miso = miso;
_mosi = mosi;
_ss = ss;
}
```
We're looking for the defaults not explicitly stated in the declaration
`Adafruit_SSD1331(&SPI, oled_csn, oled_dc, oled_resn);` specifically (`MOSI`
and `SCLK`) - however here it appears `MISO` is pin 12 and `SCK` is 15 (we
are expecting `MOSI`=15 and `SCK`=14) when `_spi_num != VSPI`.
TODO: where is `_spi_num` defined?
The last line of file `SPI.cpp`
```
SPIClass SPI(VSPI);
```
Note in `MAIN_ESP32_HAL_SPI_H_`
(.\Arduino\hardware\espressif\esp32\cores\esp32\esp32-hal-spi.h)
```
#define VSPI 3 //SPI bus normally attached to pins 5, 18, 19 and 23, but
can be matrixed to any pins
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#8
|
hello @emard and thank you for your prompt response. yes, I saw your ESP32 web-JTAG project (looks very interesting, btw) ... but that's only the ESP32 part and not the small help of FPGA logic which I think may be the issue in my case. Does your standard passthru include the right pins for the HWSPI OLED display? If not - what specific small help of FGPA is needed? :) Specifically, here's what (I believe) the passthru does:
I have more documentation on that in my WIP example here Unfortunately, I've not been able to get your LibXSVF-ESP to compile. After chasing all the dependencies, I have this error on the tft.nop():
Are you using this one: https://github.com/sumotoy/SSD_13XX ? Is this the line where you instantiate HWSPI for the display?
it was my understanding that the ESP32 WROOM-32 device can use both the SD and OLED at the same time. The Adafruit code even has this comment:
but let's see if I can simply get the HWSPI OLED working solo first. thanks a lot for your help. :) |
HI
I have emard's SSD_13XX on my github
the firmware is still somehow difficult to compile
yes, in passthru bitstream is already everything
needed for OLED to work over hardware SPI
…On 6/6/19, gojimmypi ***@***.***> wrote:
hello @emard and thank you for your prompt response.
yes, I saw your [ESP32 web-JTAG](https://github.com/emard/LibXSVF-ESP)
project (looks very interesting, btw) ... but that's _only_ the ESP32 part
and not the _small help of FPGA logic_ which I think may be the issue in my
case. Does your standard
[passthru](https://github.com/emard/ulx3s-examples/tree/master/passthru)
include the right pins for the HWSPI OLED display? If not - what specific
small help of FGPA is needed? :)
Specifically, here's what (I believe) the passthru does:
```
N2 to N3 for oled_csn /CS to wifi_gpio17 (GPIO17)
P1 to L1 for oled_dc /DC to wifi_gpio16 (GPIO16)
P2 to E3 for oled_resn/RES to wifi_gpio25 (GPIO25)
P3 to J1 for oled_mosi/SDA to sd_cmd (GPIO15)
P4 to H2 for oled_clk /SCL to sd_clk (GPIO14)
```
I have more documentation on that in my WIP example
[here](https://github.com/gojimmypi/ulx3s-examples/blob/SSD1331/VisualMicro-SSD1331-Display/README.md)
Unfortunately, I've not been able to get your LibXSVF-ESP to compile. After
chasing all the dependencies, I have this error on the
[tft.nop()](https://github.com/emard/LibXSVF-ESP/blob/master/examples/websvf_sd/keyboard.cpp#L13):
```
'class SSD_13XX' has no member named 'nop'
```
Are you using this one: https://github.com/sumotoy/SSD_13XX ?
Is
[this](https://github.com/emard/LibXSVF-ESP/blob/master/examples/websvf_sd/disp.cpp#L5)
the line where you instantiate HWSPI for the display?
```
SSD_13XX tft = SSD_13XX(__CS_TFT, __DC_TFT);
```
it was my understanding that the ESP32 WROOM-32 device _can_ use both the SD
and OLED at the same time. The [Adafruit
code](https://github.com/adafruit/Adafruit-SSD1331-OLED-Driver-Library-for-Arduino/blob/master/examples/LCDGFXDemo/LCDGFXDemo.ino#L40)
even has this comment:
>// Option 2: must use the hardware SPI pins
>// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
>// an output. This is much faster - also required if you want
>// to use the microSD card (see the image drawing example)
>#pragma message "Using HWSPI"
>Adafruit_SSD1331 display = Adafruit_SSD1331(&SPI, cs, dc, rst);
but let's see if I can simply get the HWSPI OLED working solo first.
thanks a lot for your help. :)
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#8 (comment)
|
ah yes, your version of SSD_13XX. Indeed a bit difficult but I now have your websvf_sd compiled and working. Well, more specifically I see output on the serial port. The display is blank. I instead then tried using your pre-compiled websf_sd - and in this case the display does seem to work - well, at least it is not blank: an IP address is shown. The question then: was the source for If the pre-compiled version is using HWSPI, then I would assume that shows the FPGA properly configured, agreed? For the version I compiled (non-working display), here are the pins being used:
There's a note in the README
however my
I've made no edits to my |
Yea, you have to somehow modify/fix sources in the
SPI driver to use port of ESP32 with pins that are shared
with SD card
it works if it is showing IP address
…On 6/6/19, gojimmypi ***@***.***> wrote:
ah yes, [your version of SSD_13XX](https://github.com/emard/SSD_13XX).
Indeed a bit difficult but I now have your
[websvf_sd](https://github.com/emard/LibXSVF-ESP/tree/master/examples/websvf_sd)
compiled and working. Well, more specifically I see output on the serial
port. The display is blank.
I instead then tried using your [pre-compiled
websf_sd](https://github.com/emard/ulx3s-bin/blob/master/esp32/upload-executable.sh)
- and in this case the display _does_ seem to work - well, at least it is
not blank: an IP address is shown. The question then: was the
[source](https://github.com/emard/LibXSVF-ESP/tree/master/examples/websvf_sd)
for `websvf_sd/websvf_sd.ino.partitions.bin` using HWSPI? Clearly something
is different between the working pre-compiled version and the source code.
If the pre-compiled version _is_ using HWSPI, then I would assume that shows
the FPGA properly configured, agreed?
For the _version I compiled_ (non-working display), here are the pins being
used:
```
__CS_SD =13
__MOSI_TFT =15
__MISO_TFT =2
__SCL_TFT =14
__DC_TFT =16
__CS_TFT =17
__RES_TFT =25
```
There's a note in the
[README](https://github.com/emard/LibXSVF-ESP/blob/master/README.md)
> In ESP32 arduino support directory, edit file "SD.cpp"
```
// spi.begin(int8_t sck, int8_t miso, int8_t mosi, int8_t ss)
spi.begin(14, 12, 13, -1); // v1.7
spi.begin(14, 2, 15, -1); // v1.8 and higher
```
however my `SD.cpp` has only one instance of `spi.begin()` with no
parameters.
```
bool SDFS::begin(uint8_t ssPin, SPIClass &spi, uint32_t frequency, const
char * mountpoint)
{
if(_pdrv != 0xFF) {
return true;
}
spi.begin();
_pdrv = sdcard_init(ssPin, &spi, frequency);
if(_pdrv == 0xFF) {
return false;
}
if(!sdcard_mount(_pdrv, mountpoint)){
sdcard_unmount(_pdrv);
sdcard_uninit(_pdrv);
_pdrv = 0xFF;
return false;
}
_impl->mountpoint(mountpoint);
return true;
}
```
I've made no edits to my `SD.cpp` at this time.
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#8 (comment)
|
It appears the HWSPI is using these values in
From the schematic, there's a note for
Those pins do not appear to be in the FPGA passthru, so I modified the passthru.v to include these lines in the module declaration:
and these assignment edits for
I didn't know what to do with I left the other assignment the same:
And still, the HWSPI display does not work. With the non-modified passthru, I can get the slower SWSPI working. Any other tips for HWSPI? Thanks |
well It was a long time I was doing it for the firmware
so I can help you from the memory.
It is absolutely possible to get hardware SPI working with OLED
using default passthru.
Maybe you got confused with old v1.7 notes on schematics, that's
now obsolete. Follow only the wires and where they lead to. I updated
schematics cleaning up from v1.7
Pins that are now going to FPGA JTAG cannot be
used for anything else but JTAG so passthru bitstream won't pass them thru.
Only pins that are verified in practice that work are those shared with SD
and 1-2 years agoi I had to to modify esp32arduino's SPI sources to change
default pinout, I don't know if recent sources have more clean way of setting
the pinout or again editing the source...
…On 6/7/19, gojimmypi ***@***.***> wrote:
It appears the HWSPI is using these values in `SPIClass::begin` found in the
ESP32 `SPI.cpp` file:
```
// SPIClass _sck=18
// SPIClass _miso=19
// SPIClass _mosi=23
```
From the schematic, there's a note for `VSPI` using those same pins (is VSPI
considered HWSPI?)
```
ESP32 VSPI pins
GPIO5: SS
GPIO18: SCK
GPIO19: MISO
GPIO23: MOSI
```
Those pins do not appear to be in the FPGA passthru, so I modified the
[passthru.v](https://github.com/emard/ulx3s-examples/blob/master/passthru/DiamondVerilog/passthru.v)
to include these lines in the module declaration:
```
// HWSPI
inout wire wifi_gpio5, // GPIO5
input wire jtag_tck, // GPIO18
inout wire jtag_tdo, // GPIO19
inout wire jtag_tdi, // GPIO23
```
and these assignment edits for `clk` and `mosi`:
```
assign S_oled_csn = wifi_gpio5; // was wifi_gpio17;
assign oled_csn = S_oled_csn;
assign oled_clk = jtag_tck; // GPIO18 was // sd_clk WiFi_GPIO14
assign oled_mosi = jtag_tdi; // GPIO23; was // WiFi GPIO15
```
I didn't know what to do with `GPIO19` (`JTAG_TDO`) for `MISO` as there's
only a `MOSI` connector on the display.
I left the other assignment the same:
```
#define oled_csn 5 // aka cs was 17
#define oled_dc 16 // aka ds
#define oled_resn 25 // aka rst
#define oled_mosi 23 // aka mosi was 15
#define oled_clk 18 // aka sclk was 14
```
And still, the HWSPI display does not work. With the non-modified passthru,
I can get the slower SWSPI working. Any other tips for HWSPI? Thanks
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#8 (comment)
|
I believe I have determined why my ULX3S SSD1331 display does not work with the Adafruit Arduino library when attempting to instantiate hardware SPI (aka According to the comments in the Espressif example:
The default hardware SPI is the
Alternatively, the other hardware SPI is the
The current passthru implementation is using the
Note also the inconsistency on Further exacerbating my problem, is that when making the changes to the FPGA passthru (mentioned above) to use the default VSPI pins to prove and fix this, I had not noticed these warnings in Lattice Diamond:
Here's the JTAG section of the constraint file with the desired pins uncommented:
Admittedly, I'm a FPGA newbie, and I have no idea why Diamond is complaining about these pin locations. If you can provide some tips on how to passthru to use SCLK = 18, MISO = 19, MOSI = 23, SS = 5 for the VSPI default, I can work on this further. Here's my ECP5 setting: I do have another SSD-1331 display that should arrive later today to test with a stand-alone ESP32 WROOM-32 board. In the meantime, although I agree that as you said:
(but with other code, but not with the Arduino libraries expecting VSPI default) What do you think? Do you agree? What I suggest is that the passthru perhaps be modified to use the |
I forgot to add that regarding changing esp32arduino's SPI sources - that's not very practical. The only option for the end user would be to add conditional board type... the ULX3S? It's not really - as it is actually the ESP32 board. I'm also curious about the FPGA JTAG cannot be used for anything else but JTAG comment. Can you provide more details? |
In the question is also the answer - they list DEFAULT pinout for
xSPI and default can be changed to something custom.
It is ESP32 firware to work on not passthru bitstream.
It is not possible to force ECP5 fpga to use it's JTAG pins
as GPIO, therefore you got this
"WARNING - Specified location site name "T5" is not valid for..."
OTOH It is possible to let ESP32 change its pins for xSPI interfaces.
…On 6/9/19, gojimmypi ***@***.***> wrote:
I forgot to add that regarding changing esp32arduino's SPI sources - that's
not very practical. The only option for the end user would be to add
conditional board type... the ULX3S? It's not really - as it is actually the
ESP32 board.
I'm also curious about the _FPGA JTAG cannot be used for anything else but
JTAG_ comment. Can you provide more details?
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#8 (comment)
|
As hardware SPI from ESP32 works to SD card and OLED in my firmware |
I am unable to get the SSD-1331 display working in HWSPI (fast) mode. I'm wondering if the SPI pins are connected the same as the default ESP-Dev-Module (WROOM-32). I'm thinking perhaps not.
I was able to get the ESP32 to use the SSD-1331 display in SWSPI (slow) mode. using these pin definitions and the passthru code loaded on the FPGA:
For the SWSPI, the
option 1
in the Adafruit LCDGFXDemo example, the display is instantiated like this:For HWSPI, the display is instead instantiated like this:
I have some addition notes in my SSD1331 Branch of Examples and duplicated here:
Arduino Implmentation Notes
This an Arduino-style solution, suitable for use with either the Ardunio IDE,
or Visual Micro. The display can be initialized either with this software SPI, which is
perhaps more flexible but a little slower:
... or the alternative is this hardware SPI instantiation (untested / not working at this time):
Note the comments in the Adafruit code:
As the ULX3S appears to use different pins, is HWSPI even possible? The
cs
,dc
,rst
pins do not seem to be otherwise defined without the macros.The
&SPI
is defined in%USERPROFILE%\Documents\Arduino\hardware\espressif\esp32\libraries\SPI\src\SPI.cpp
of interest, is this initialization code:We're looking for the defaults not explicitly stated in the declaration
Adafruit_SSD1331(&SPI, oled_csn, oled_dc, oled_resn);
specifically (MOSI
andSCLK
) - however here it appearsMISO
is pin 12 andSCK
is 15 (we are expectingMOSI
=15 andSCK
=14) when_spi_num != VSPI
.TODO: where is
_spi_num
defined?The last line of file
SPI.cpp
Note in
MAIN_ESP32_HAL_SPI_H_
(.\Arduino\hardware\espressif\esp32\cores\esp32\esp32-hal-spi.h)The text was updated successfully, but these errors were encountered: