GPIO pins on controller

Can anyone tell me if he ENABLE pin from Add-on1 is GPIO pin?
If not, if there is anyother Pin which can be used from other Add-ons?

All the addons are actually controller using a CAN bus. Maybe check this out: Custom Extension Module

I think generally it’s a safe assumption that all pins for the plugs are GPIO pins. Why do you ask?

Most of the pins are defined in: Snapmaker2-Controller/pins_GD32F1.h at b73076557491cdd7e014a8771caa621c6c009f10 · Snapmaker/Snapmaker2-Controller · GitHub

I am trying to use one of the pins, here for example PE13 (Add-on1 STEP PIN) to control a valve like a seecond extruder:
Stepper.cpp

  #elif HAS_E0_STEP
  // Trigger to start Valve printing.
    if(current_block->extruder == 1){
      if(step_needed[E_AXIS]){
      pinMode(PE13, OUTPUT);        
      extDigitalWrite(PE13, HIGH);

      } 
    }  

But its not changing and giving me a constant 5V. I knwo the moachine is switching to Extruder 1 from 0 becuase I have given an offset between them and when I switch from T0 to T1, the machine moves. but i am not getting any signal out from the pin PE13 when I a measuring it after giving extrusion value
.

// 8 PIN port from top to bottom

#define PORT_TO_STEP_PIN { /STEP DIR ENABLE/ \

/* PORT_8PIN_1 */ {PE14, PB10, PB11}, \

/* PORT_8PIN_2 */ {PE13, PC10, PC11}, \

/* PORT_8PIN_3 */ {PC6 , PD15, PA3 }, \

/* PORT_8PIN_4 */ {PB4 , PB3, PB5 }, \

/* PORT_8PIN_5 */ {PB7 , PB6, PA2 }, \

/* PORT_8PIN_6 */ {PA1 , PC12, PD2 }, \

}

PE13 is from PORT2, which is unsed Add-on 1.

These external digital writing of high and low are only possible on GPIO pins, therefore I was wondering which pins are GPIO pins

With the tools I have in front of me at the moment (only notepad++) I cannot adequately trace these functions throughout the code. Need vscode.

Will have to look later. If the pin is not being referenced elsewhere in the ISR to be controlled then I can’t say.

The chip is a GD32F305VGT6, pull up the datasheet and you can find out
image

All of the named ports are GPIOs. There may be an alternate function mapped by default, would have to read through the user manual to verify the pin is configured correctly.

https://www.gigadevice.com/microcontroller/gd32f305vgt6/

Configuring GPIO pins starts on page 175

Wow. Thank you.

Well only the E1_DIR_pin is used in rotary module:

and PE13 has only these references :slight_smile:

Unfortuantely it’s not that simple, because then you will have to trace all references of E1_STEP_PIN and so on recursively. Ultimately it traces back to AXIS_INIT and other very general macros that are included with various conditional includes.

image

While using RUmba32, I used the similar method, to use a GPIO pin to run the valve as extruder 2, and thats what I am trying to replicate here. I need the valve to open and close like an extruder. therefore I am trying to tap the GPIO pin on the module.

Yea in theory I think it’ll work, just going to take some time to find out.

This is the only place where I see it. I dont understand how this would interfere in using it to turn it high or low

How should I go about it then ?

Yes that’s the next step of tracing, now you would continue recursively.

I dont understand how to trace it recursively. These are reference to the pin, and out of the options, only the ones in, stepperindirection.h have are valid and even their definitions seem to be harmless to me.

#elif E_STEPPERS > 1

#if E_STEPPERS > 5

#define _E_STEP_WRITE(E,V) do{ switch (E) { case 0: E0_STEP_WRITE(V); break; case 1: E1_STEP_WRITE(V); break; case 2: E2_STEP_WRITE(V); break; case 3: E3_STEP_WRITE(V); break; case 4: E4_STEP_WRITE(V); case 5: E5_STEP_WRITE(V); } }while(0)

#define   _NORM_E_DIR(E)   do{ switch (E) { case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 2: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 3: E3_DIR_WRITE(!INVERT_E3_DIR); break; case 4: E4_DIR_WRITE(!INVERT_E4_DIR); case 5: E5_DIR_WRITE(!INVERT_E5_DIR); } }while(0)

#define    _REV_E_DIR(E)   do{ switch (E) { case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; case 2: E2_DIR_WRITE( INVERT_E2_DIR); break; case 3: E3_DIR_WRITE( INVERT_E3_DIR); break; case 4: E4_DIR_WRITE( INVERT_E4_DIR); case 5: E5_DIR_WRITE( INVERT_E5_DIR); } }while(0)

#elif E_STEPPERS > 4

#define _E_STEP_WRITE(E,V) do{ switch (E) { case 0: E0_STEP_WRITE(V); break; case 1: E1_STEP_WRITE(V); break; case 2: E2_STEP_WRITE(V); break; case 3: E3_STEP_WRITE(V); break; case 4: E4_STEP_WRITE(V); } }while(0)

#define   _NORM_E_DIR(E)   do{ switch (E) { case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 2: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 3: E3_DIR_WRITE(!INVERT_E3_DIR); break; case 4: E4_DIR_WRITE(!INVERT_E4_DIR); } }while(0)

#define    _REV_E_DIR(E)   do{ switch (E) { case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; case 2: E2_DIR_WRITE( INVERT_E2_DIR); break; case 3: E3_DIR_WRITE( INVERT_E3_DIR); break; case 4: E4_DIR_WRITE( INVERT_E4_DIR); } }while(0)

#elif E_STEPPERS > 3

#define _E_STEP_WRITE(E,V) do{ switch (E) { case 0: E0_STEP_WRITE(V); break; case 1: E1_STEP_WRITE(V); break; case 2: E2_STEP_WRITE(V); break; case 3: E3_STEP_WRITE(V); } }while(0)

#define   _NORM_E_DIR(E)   do{ switch (E) { case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 2: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 3: E3_DIR_WRITE(!INVERT_E3_DIR); } }while(0)

#define    _REV_E_DIR(E)   do{ switch (E) { case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; case 2: E2_DIR_WRITE( INVERT_E2_DIR); break; case 3: E3_DIR_WRITE( INVERT_E3_DIR); } }while(0)

#elif E_STEPPERS > 2

#define _E_STEP_WRITE(E,V) do{ switch (E) { case 0: E0_STEP_WRITE(V); break; case 1: E1_STEP_WRITE(V); break; case 2: E2_STEP_WRITE(V); } }while(0)

#define   _NORM_E_DIR(E)   do{ switch (E) { case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 2: E2_DIR_WRITE(!INVERT_E2_DIR); } }while(0)

#define    _REV_E_DIR(E)   do{ switch (E) { case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; case 2: E2_DIR_WRITE( INVERT_E2_DIR); } }while(0)

#else

#define _E_STEP_WRITE(E,V) do{ if (E == 0) { E0_STEP_WRITE(V); } else { E1_STEP_WRITE(V); } }while(0)

#define   _NORM_E_DIR(E)   do{ if (E == 0) { E0_DIR_WRITE(!INVERT_E0_DIR); } else { E1_DIR_WRITE(!INVERT_E1_DIR); } }while(0)

#define    _REV_E_DIR(E)   do{ if (E == 0) { E0_DIR_WRITE( INVERT_E0_DIR); } else { E1_DIR_WRITE( INVERT_E1_DIR); } }while(0)

#endif

you might appreciate this if you haven’t already seen it Get Started - default (Workspace) - Visual Studio Code (vscode.dev)

Oh, I have a set up at home, I’m just at work right now lol.

thats why the web version is great if you can’t install something, though i suspect you are more about the 'i can’t get distracted at work :slight_smile: )

1 Like