🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    M5Stack Core2 pin config problems

    Core 2
    3
    8
    645
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      Phil_C
      last edited by

      Hi, I am trying to get a project running on a Core2, I am getting errors related to the GPIO config.

      I am using PIO in VSC, my PIO environment is setup as follows.

      release (board: m5stack-core2; platform: espressif32; framework: arduino)
      

      These are the GPIO config errors I am getting

      Initialising Hardware 
      E (467) gpio: GPIO can only be used as input mode
      [   495][E][esp32-hal-gpio.c:130] __pinMode(): GPIO config failed
      E (484) gpio: GPIO can only be used as input mode
      [   511][E][esp32-hal-gpio.c:130] __pinMode(): GPIO config failed
      E (494) gpio: GPIO can only be used as input mode
      [   522][E][esp32-hal-gpio.c:130] __pinMode(): GPIO config failed
      E (504) gpio: GPIO can only be used as input mode
      [   532][E][esp32-hal-gpio.c:130] __pinMode(): GPIO config failed
      E (514) gpio: GPIO can only be used as input mode
      [   542][E][esp32-hal-gpio.c:130] __pinMode(): GPIO config failed
      E (525) gpio: GPIO can only be used as input mode
      [   553][E][esp32-hal-gpio.c:130] __pinMode(): GPIO config failed
      E (535) gpio: GPIO can only be used as input mode
      [   563][E][esp32-hal-gpio.c:130] __pinMode(): GPIO config failed
      E (545) gpio: GPIO can only be used as input mode
      [   573][E][esp32-hal-gpio.c:130] __pinMode(): GPIO config failed
      E (556) gpio: GPIO can only be used as input mode
      [   583][E][esp32-hal-gpio.c:130] __pinMode(): GPIO config failed
      

      This is my pins.h configuration
      I have used 100 for pins that are not currently used/required in the project.

      /***********************************************************
       * M5STACK CORE2
       * UNTESTED
       * NOTE M5STACK CORE2 has SD card on GPIOs 4/23/38/18
       *
        ***/
      #ifdef M5_STACK_CORE2
      
          #define BOARD_TYPE              "m5stack-core2"
      
          // Define Physical Pins
          
          // VAC CONTROL
          #define VAC_SPEED_PIN               100                      // Built in DAC1 - used for speed reference for VFD (0-3v)
          #define VAC_BLEED_VALVE_PIN         100                      // Built in DAC2 - used for bleed valve control
          
          #define VAC_BANK_1_PIN              100                      // vac motor(s) on/off
          #define VAC_BANK_2_PIN              100                      // Provision for 2 stage Vac motor control
          #define VAC_BANK_3_PIN              100                      // Provision for 3 stage Vac motor control
          
          // SENSORS
          #define SPEED_SENSOR_PIN            100                      // turbine / rotor speed for turbo / blower flow bench
      
           // SWIRL ENCODER
          #define SWIRL_ENCODER_PIN_A         100
          #define SWIRL_ENCODER_PIN_B         100
      
         // ORIFICE DETECTION                                                                                    
          #define ORIFICE_BCD_BIT1_PIN        100                     
          #define ORIFICE_BCD_BIT2_PIN        100                    
          #define ORIFICE_BCD_BIT3_PIN        100     
      
          //STEPPER MOTOR CONTROLLER                  
          #define FLOW_VALVE_STEP_PIN         100
          #define FLOW_VALVE_DIR_PIN          100
                        
          #define AVO_STEP_PIN                100
          #define AVO_DIR_PIN                 100
      
          #define VCC_3V3_PIN                 100                     // Unused
          #define VCC_5V_PIN                  2                      // 10k-10k divider across 5v supply
          
          // NOTE: these inputs are handled by ADC
          #define MAF_PIN                     100                     // NOTE: I2C ADC is used instead
          #define REF_PRESSURE_PIN            100                     // NOTE: I2C ADC is used instead
          #define DIFF_PRESSURE_PIN           100                     // NOTE: I2C ADC is used instead
          #define PITOT_PIN                   100                     // NOTE: I2C ADC is used instead
          
          // NOTE: These inputs are handled by BME280
          #define TEMPERATURE_PIN             100                     // NOTE: I2C BME280 used
          #define REF_BARO_PIN                100                     // NOTE: I2C BME280 used
          #define HUMIDITY_PIN                100                     // NOTE: I2C BME280 used                     
          
          // COMMS    
          #define SERIAL0_TX_PIN              1                      // API
          #define SERIAL0_RX_PIN              3                      // API
          #define SERIAL2_TX_PIN              100                     // GAUGE PROTOCOL CLOCK
          #define SERIAL2_RX_PIN              100                     // GAUGE PROTOCOL DATA
          #define SDA_PIN                     32                     // BME280 etc
          #define SCL_PIN                     33                     // BME280 etc
          
          //#define SD_CS_PIN                   4
          //#define SD_MOSI_PIN                 23                 
          //#define SD_MISO_PIN                 38             
          //#define SD_SCK_PIN                  18                   
      
      #endif
      

      I hope someone here can help me resolve my problem.
      Thanks.

      felmueF 1 Reply Last reply Reply Quote 0
      • felmueF
        felmue @Phil_C
        last edited by

        Hello @Phil_C

        instead of 100 for non used GPIOs have you tried -1?

        Thanks
        Felix

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

        P 1 Reply Last reply Reply Quote 0
        • P
          Phil_C @felmue
          last edited by Phil_C

          @felmue thanks, that has made a difference and given me a working I2C bus and prevents the crashing.

          I am still curious to know what is causing the following messages during hardware initialisation, this is now displayed since changing the pins to -1

          Initialising Hardware 
          [   494][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected
          [   507][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected
          [   513][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected
          [   519][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected
          [   525][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected
          [   531][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected
          [   538][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected
          [   544][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected
          [   550][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected
          [   556][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected
          [   562][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected
          [   568][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected
          [   574][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected
          [   580][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected
          
          ajb2k3A 1 Reply Last reply Reply Quote 0
          • ajb2k3A
            ajb2k3 @Phil_C
            last edited by

            @Phil_C In all honesty its actually telling you what's wrong.
            What part or the messages are you not understanding?

            UIFlow, so easy an adult can learn it!
            If I don't know it, be patient!
            I've ether not learned it or am too drunk to remember it!
            Author of the WIP UIFlow Handbook!
            M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

            felmueF P 2 Replies Last reply Reply Quote 0
            • felmueF
              felmue @ajb2k3
              last edited by

              Hello @Phil_C

              you could also try to not define the not used GPIO, e.g. comment out those lines. Maybe that is a better approach than setting it to -1 as I suggested before.

              Thanks
              Felix

              GPIO translation table M5Stack / M5Core2
              Information about various M5Stack products.
              Code examples

              P 1 Reply Last reply Reply Quote 0
              • P
                Phil_C @ajb2k3
                last edited by Phil_C

                @ajb2k3 I understand the message, I just don't understand where it is coming from.
                I believe it is related to the board type in platformio I have my environment set up as

                platform = espressif32
                framework = arduino
                board = m5stack-core2
                

                If I change the board type to

                platform = espressif32
                framework = arduino
                board = esp32-s3-devkitc-1
                

                Then I don't get the error messages about the invalid pins, I am reasonably new to all this so just trying to better my understanding.

                Is it that the board type m5stack-core2 is it looking for the pins already used on the M5Stack Core2?

                1 Reply Last reply Reply Quote 0
                • P
                  Phil_C @felmue
                  last edited by Phil_C

                  @felmue Thanks again, I have tried this already and it causes issue with the code, which has not been written by me so more difficult to work though currently.

                  Currently the unused pins that are defined in the code are there as place holders for future development of the code and parts of which have not been written yet

                  It looks the problem is coming from the board type defined in the environment in platformio. See my comments in the replies above.

                  Appreciate your help.

                  1 Reply Last reply Reply Quote 0
                  • P
                    Phil_C
                    last edited by

                    I managed to resolve the issue I was having by editing the hardware.cpp of the project from

                      pinMode(VCC_3V3_PIN, INPUT); 
                    

                    to

                      #ifdef VCC_3V3_PIN
                      pinMode(VCC_3V3_PIN, INPUT); 
                      #endif
                    

                    This has then enabled me to comment out the unused pins in the pins.h

                    @felmue and @ajb2k3 thanks for your help

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post