gpio: gpio_set_level(226): GPIO output gpio_num error

PI12EMSE
Posts: 1
Joined: Fri Jun 02, 2023 9:00 am

gpio: gpio_set_level(226): GPIO output gpio_num error

Postby PI12EMSE » Fri Jun 02, 2023 9:21 am

Hello,

I have a problem concerning the writing of the pins. I want to put them to 1 to drive a Multiplexers (MUXO & MUXI in the code below) but when i try to control MUXI, i have the error code in the Serial terminal "E (X) gpio: gpio_set_level(226): GPIO output gpio_num error" and i don't know why there is this problem neither how to fix it.
  1. #include "MUX.h"
  2.  
  3. //Define Utilisateur
  4. #define DEBUG 1
  5. #define i 16
  6. #define j 16
  7.  
  8. //Define connection pins on ESP32
  9. #define S0_MUXO 2
  10. #define S1_MUXO 15
  11. #define S2_MUXO 14
  12. #define S3_MUXO 18
  13. #define SIG_MUXO 33
  14. #define EN_MUXO 27
  15.  
  16.  
  17. #define S0_MUXI 35
  18. #define S1_MUXI 34
  19. #define S2_MUXI 3
  20. #define S3_MUXI 1
  21. #define SIG_MUXI 32
  22. #define EN_MUXI 21
  23.  
  24. int a = 0;
  25. int b = 0;
  26. int c = 0;
  27.  
  28.  
  29. MUX muxi = MUX(S0_MUXI, S1_MUXI, S2_MUXI, S3_MUXI, SIG_MUXI, EN_MUXI, MUXI);
  30. MUX muxo = MUX(S0_MUXO, S1_MUXO, S2_MUXO, S3_MUXO, SIG_MUXO, EN_MUXO, MUXO);
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37. void setup() {
  38.     Serial.begin(115200);
  39.    
  40.  
  41.     muxo.enable();
  42.     muxi.enable();
  43.  
  44. }
  45.  
  46. void loop() {
  47.     //CODE PRINCIPALE
  48.         while (a < j) {
  49.  
  50.             muxi.choix_channel(a);
  51.             muxi.ON();
  52.             while (b < i) {
  53.                 muxo.choix_channel(b);
  54.                 c = a + b;
  55.                 b++;
  56.             }
  57.             b = 0;
  58.             a++;
  59.         }
  60.  
  61.         a = 0;
  62.  
  63.  
  64.  
  65.     if (DEBUG) {
  66.         Serial.println("End loop");
  67.     }
  68. }
  1. #include "esp32-hal-gpio.h"
  2. #include "MUX.h"
  3.  
  4.  
  5.  
  6. MUX::MUX(int S0, int S1, int S2, int S3, int SIG, int EN, TYPE _type) {
  7.  
  8.     pin_S0 = S0;
  9.     pin_S1 = S1;
  10.     pin_S2 = S2;
  11.     pin_S3 = S3;
  12.     pin_EN = EN;
  13.     pin_SIG = SIG;
  14.     type = _type;
  15.  
  16.     pinMode(pin_EN, OUTPUT);
  17.     digitalWrite(pin_EN, LOW);
  18.     pinMode(pin_S0, OUTPUT);
  19.     pinMode(pin_S1, OUTPUT);
  20.     pinMode(pin_S2, OUTPUT);
  21.     pinMode(pin_S3, OUTPUT);
  22.     digitalWrite(pin_S0, LOW);
  23.     digitalWrite(pin_S1, LOW);
  24.     digitalWrite(pin_S2, LOW);
  25.     digitalWrite(pin_S3, LOW);
  26.  
  27.     if (type == MUXO) {
  28.         pinMode(pin_SIG, INPUT_PULLDOWN);
  29.     }
  30.     if (type == MUXI) {
  31.         pinMode(pin_SIG, OUTPUT);
  32.     }
  33. }
  34.  
  35.  
  36. void MUX::disable() {
  37.  
  38.     digitalWrite(pin_EN, HIGH);
  39. }
  40.  
  41. void MUX::enable() {
  42.  
  43.     digitalWrite(pin_EN, LOW);
  44. }
  45.  
  46.  
  47.  
  48. void MUX::ON() {
  49.  
  50.     if (type == MUXI) {
  51.         digitalWrite(pin_SIG, HIGH);
  52.     }
  53. }
  54.  
  55. void MUX::OFF() {
  56.  
  57.     if (type == MUXI) {
  58.         digitalWrite(pin_SIG, LOW);
  59.     }
  60. }
  61.  
  62. void MUX::choix_channel(int ch) {
  63.  
  64.  
  65.     digitalWrite(pin_S0, LOW);
  66.     digitalWrite(pin_S1, LOW);
  67.     digitalWrite(pin_S2, LOW);
  68.     digitalWrite(pin_S3, LOW);
  69.  
  70.     if (ch & 0b0001) {
  71.         digitalWrite(pin_S0, HIGH);
  72.     }
  73.     if (ch & 0b0010) {
  74.         digitalWrite(pin_S1, HIGH);
  75.     }
  76.     if (ch & 0b0100) {
  77.         digitalWrite(pin_S2, HIGH);
  78.     }
  79.     if (ch & 0b1000) {
  80.         digitalWrite(pin_S3, HIGH);
  81.     }
  82. }
  83.  
  84.  
  85. MUX::~MUX() {
  86.     true == true;
  87. };
  1. #pragma once
  2. #ifndef MUX_h
  3. #define MUX_h
  4.  
  5. #include "Arduino.h"
  6.  
  7. enum TYPE { MUXO, MUXI };
  8.  
  9. class MUX {
  10. public:
  11.     int pin_S0;
  12.     int pin_S1;
  13.     int pin_S2;
  14.     int pin_S3;
  15.     int pin_EN;
  16.     int pin_SIG;
  17.     TYPE type;
  18.  
  19.     MUX(int S0, int S1, int S2, int S3, int EN, int SIG, TYPE _type);
  20.     ~MUX();
  21.  
  22.     void choix_channel(int ch);
  23.     void enable();
  24.     void disable();
  25.     void ON();
  26.     void OFF();
  27.  
  28.  
  29.  
  30. };
  31. #endif

Thanks for your help

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: gpio: gpio_set_level(226): GPIO output gpio_num error

Postby lbernstone » Sat Jun 03, 2023 6:11 pm

I didn't really look at your code, but pins 34&35 are input only.

Who is online

Users browsing this forum: No registered users and 70 guests