Initialize pins in separate cpp file

Good question...

In a nutshell...

I am able to get it to compile and work in PlatformIO. Does that mean it requires it, I honestly am not sure.

It uses a main.cpp instead of a main.ino.

The plantformIO is configured so I can compile the code and then upload the firmware.elf to the BTT Octopus via STM32CubeProgrammer.

I honestly and learning on this board as it is designed for Marlin and 3D Printers, but I am using it for a personal automation project.

What I would like to do is fully develop the IO for the entire board and contribute it for everyone to use on github.

It is mostly straight forward and I have programmed in the manner that I am trying to accomplish without issue, I just do not know why a tried and true coding method is not working when the newbie coding style works.

It works with the clunkier code style, but it can, and I can do better.

I want to make it a project like Marlin, something everyone can use with a github download.

this is where i got the help to get this far:

I just want to contribute back with a github OOBE (Out Of Box Experience) contribution.

-Jason

@gcjr , @Koepel , @UKHeliBob , @DrDiettrich

Thank all of you for your help. I had to get some sleep and pull out my oscilloscope. When I would touch the STEP pin on the motor it would turn, but the signal looked horrible.

it helps if I code it correctly when initializing the pins, lol

// Here is the code I had for initializing my steppers
// As you can see I was not assigning the dwMode , lol

// void pinMode(uint32_t dwPin, uint32_t dwMode)

//So when I was setting the mode to LOW, it set the pinMode to an INPUT. So that is why it did not work at all and responded when I put the O-Scope probe on the step pin.

OUTPUT = 0x1
INPUT = 0x0
INPUT_PULLUP = 0x2
INPUT_PULLDOWN = 0x3

LOW = 0x0
HIGH = 0x1

  for (int i = 0; i <= 7; i++) { // Initialize Steppers
    pinMode(STEPPERS[i][MOT_STEP], LOW);
    pinMode(STEPPERS[i][MOT_DIRECTION], LOW);
    pinMode(STEPPERS[i][MOT_ENABLE], MOTOR_DISABLE);
    pinMode(STEPPERS[i][MOT_CS], LOW);
  }



// This is how I should have coded it.
// Sleep is necessary, lol

  for (int i = 0; i <= 7; i++) { // Initialize Steppers
    pinMode(STEPPERS[i][MOT_STEP], OUTPUT);
    pinMode(STEPPERS[i][MOT_DIRECTION], OUTPUT);
    pinMode(STEPPERS[i][MOT_ENABLE], OUTPUT);
    pinMode(STEPPERS[i][MOT_CS], OUTPUT);
  }


Thanks,
Jason

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.