Skip to content
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

[ 707][E][esp32-hal-gpio.c:95] __pinMode(): Invalid pin selected #1767

Closed
homonto opened this issue Apr 10, 2022 · 15 comments
Closed

[ 707][E][esp32-hal-gpio.c:95] __pinMode(): Invalid pin selected #1767

homonto opened this issue Apr 10, 2022 · 15 comments

Comments

@homonto
Copy link

homonto commented Apr 10, 2022

hi Bodmer,

My pins are defined in custom config this way:

#define ST7789_DRIVER      // Full configuration option, define additional parameters below for this display
#define TFT_WIDTH  240 // ST7789 240 x 240 and 240 x 320
#define TFT_HEIGHT 240 // ST7789 240 x 240
#define TFT_CS   -1  // Chip select control pin, use -1 if not in use
#define TFT_RST   2 
#define TFT_DC    3  
#define TFT_MOSI 4
#define TFT_SCLK 5
#define TFT_MISO -1  // use -1 if not in use

Whenever I start the program it shows me this error:

12:46:39.679 -> [   707][E][esp32-hal-gpio.c:95] __pinMode(): Invalid pin selected
12:46:39.679 -> E (271) gpio: gpio_set_level(226): GPIO output gpio_num error
12:46:39.679 -> [   707][E][esp32-hal-spi.c:208] spiAttachMISO(): HSPI Does not have default pins on ESP32S2!
12:46:39.716 -> [   715][E][esp32-hal-gpio.c:95] __pinMode(): Invalid pin selected
12:46:39.716 -> E (285) gpio: gpio_set_level(226): GPIO output gpio_num error

Funny thing: all works.

I narrowed down that this message comes from: esp32-hal-spi.c - it is repeated there many times - see here: https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-spi.c

the moment I change "-1" in unused pins (TFT_CS and TFT_MISO) and put i.e. "40" (that does not exist btw on ESP32-S2), there is no more error

Is that a bug or so?
Apparently "-1" is not the best option if one wants to have clean code without warnings

thx

@Bodmer
Copy link
Owner

Bodmer commented Apr 10, 2022

In the Arduino world an I/O pin number of -1 is OK to signify to a function that a pin allocation is not wanted, but for low level calls it can throw a warning.
It is odd that an apparently illegal pin number does not generate an error!
Expressif seem to have put a new software team in place and this has lead to some negative impact on existing ESP32 libraries. Software engineers love to change things their predecessors did and make it "better"! I expect this will sort itself out eventually! In the meantime your workaround will be needed.

@homonto
Copy link
Author

homonto commented Apr 10, 2022

I tried to remove the number completely but then, many functions get crazy (like: "give me the number or so!")
I started with number 100 but then - not working
40 seems ok ;-)
I would give any legal number but I have one project with... all pins taken so I tried 40 and it ... looks ok ;-)

@Bodmer
Copy link
Owner

Bodmer commented Apr 10, 2022

The SPI port can operate in half duplex mode so MOSI and MISO are on same pin. So maybe try setting MISO and MOSI to pin 4.

@Bodmer
Copy link
Owner

Bodmer commented Apr 20, 2022

@homonto, I am thinking about assigning TFT_MISO = TFT_MOSI if TFT_MISO is not defined. Can you test that works OK in your setup.

@homonto
Copy link
Author

homonto commented Apr 20, 2022

@Bodmer just tell me what to do please: simply do it this way:? Compile and report back? ;-) I can do it for both ILI9341 320x240 and ST7789 240x240

#define TFT_MOSI 4 //used
#define TFT_MISO 4 //fake

@Bodmer
Copy link
Owner

Bodmer commented Apr 20, 2022

Yes, that is exactly right, thanks.

@Bodmer
Copy link
Owner

Bodmer commented Apr 20, 2022

@homonto
Copy link
Author

homonto commented Apr 20, 2022

library: 2.4.45, ILI9341: before changes (MOSI=4, MISO=40):

Before_20220420_203959

after changes (both are 4):
After_20220420_205713

the only difference I see is my hand is shaking more "after" ;-)
should I check ST7789 as well?

@homonto
Copy link
Author

homonto commented Apr 20, 2022

This link is interesting: https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-reference/peripherals/gpio.html#:~:text=The%20ESP32%2DS2%20chip%20features,GPIO21%20and%20GPIO26%20~%20GPIO46).

Looks like valid GPIO for the ESP32 S2 are 0-21 and 26-46.

GPIO40 ->JTAG

that is why, when I used MISO=40 it worked as I am not using JTAG:

@Bodmer
Copy link
Owner

Bodmer commented Apr 20, 2022

All looks good, no more testing needed. Thank you.
I like your display arrangement! Looks good.

@homonto homonto closed this as completed Apr 20, 2022
@homonto
Copy link
Author

homonto commented Apr 20, 2022

topic closed I think as solution provided ;-)
I am sure in next version you will say what exactly is to be done: keep "-1" and you redo your part or something else ;-)
btw I upgraded to 2.4.50 and all is OK as well

@Bodmer
Copy link
Owner

Bodmer commented Apr 20, 2022

Great, thanks again.

Bodmer added a commit that referenced this issue Apr 20, 2022
@Bodmer
Copy link
Owner

Bodmer commented Apr 20, 2022

Master repository updated.

@dejavu1987
Copy link

I have tried several different pins on my touch display and all of them have worked, I finally decided to solder everything and now I am getting that error, it seem to be running fine as when I touch on the screen It is logging the coordinates just the display is black, don't know if its just the LED / BL pin that is coincidentally connected to a READ ONLY PIN. FML

#define TFT_MISO 33 
#define TFT_MOSI 27
#define TFT_SCLK 12
#define TFT_CS 4 
#define TFT_RST 32
#define TFT_DC 25
#define TFT_BL 35 

#define TOUCH_CS 26 

@dejavu1987
Copy link

Indeed.
image
image

😮‍💨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants