Burning Minicore's ATMega328pb Bootloader on an A*328PB Micro?

In debugging why the Accelstepper library isn’t working on a 5V A*328PB Micro board the suggestion I’ve been given is to use Minicore to load my sketch as there seems to be an issue with the pin mappings:

Google Group

“Accdelstepper uses the core’s fast I/O tables (digitalPinToPort, digitalPinToBitMask). If those tables do not match the 328PB’s actual hardware ports, the pin will blink in a trivial sketch but AccelStepper will drive the wrong port/bit , producing no pulses on the physical pin.”

Can I burn the Minicore bootloader onto the board, and then revert it back after I’m done prototyping? I saw this post Can’t programm 328PB via TTL anymore after burning bootloader but there was no resolution.

Hello.

I do not expect replacing the bootloader on your A-Star 328PB to be a useful troubleshooting step; that seems very unlikely to be the problem. Just to be certain, I tried out a basic program using the AccelStepper library here, and it worked without incident using the default bootloader. The advice in the Google Group you linked to seems to just be someone copy and pasting answers from an AI tool, and our present recommendation with any of those types of tools is to not trust any of the information they provide unless you can verify it yourself.

If you are concerned that your A-Star is not working, then a better approach for actually troubleshooting that would be to load a simple AccelStepper program and monitor the pins with a scope to see if they are acting as you expect (i.e. check to see if there are pulses on STEP pin). If that does not work, then a good next step would be to load a program where you generate pulses without using the AccelStepper library, and that might help you identify whether the issue is related to the code or your hardware. Here is a blog post with a good example program for that.

To answer your question though, I expect it should be possible for you to burn the MiniCore bootloader to the A-Star 328PB, and you should be able to burn the original bootloader later by following the instructions from “The A-Star 328PB Serial Bootloader” section of the A-Star 328PB user’s guide.

- Patrick

Thanks Patrick. I’m going to try again and see if I can get it working. I am using a simple constant speed example sketch for debugging.

Is there any limitation on which pins I can use for AccelStepper’s STEP & DIR pins? I’ve been using A1/D15 for STEP, and D10 for DIR.

Everything works now with the following sketch using a TMC2208 SilentStepStick:

#include <AccelStepper.h>       // https://github.com/waspinator/AccelStepper

#define EN_PIN          10     // LOW: Driver enabled. HIGH: Driver disabled
#define DIR_PIN         9    // Req'd for AccelStepper (NOTE: this pin is on back row of board)
#define STEP_PIN        4    // Step on rising edge (pin A1)
#define MS1_PIN         16    // To set step mode (pin A2)
#define MS2_PIN         17    // To set step mode (pin A3)


// Set up accelStepper intance
AccelStepper stepper(AccelStepper::DRIVER, STEP_PIN, DIR_PIN);

void setup() {
  // Prepare pins
  pinMode(EN_PIN, OUTPUT);       // EN pin
  digitalWrite(EN_PIN, HIGH);   // Disable driver in hardware

  pinMode(MS1_PIN, OUTPUT);     // MS1 pin
  pinMode(MS2_PIN, OUTPUT);     // MS2 pin

  // Set up SilentStepStick in 1/2 step mode for this particular stepper motor
  digitalWrite(MS1_PIN, HIGH);
  digitalWrite(MS2_PIN, LOW);

  digitalWrite(EN_PIN, LOW);     // Enable stepper driver
  
  stepper.setMaxSpeed(1000);
  stepper.setSpeed(660.0); // default # of steps per second (1/2 step mode)
}

void loop() {
  stepper.runSpeed();
}

I changed the DIR & STEP pin assignments but I don’t think that was the real issue; it seems the screw dial on the TMC2208’s current limiting pot had separated and hence the current was 0. I swapped in a new TMC2208 and all is good.

I am glad to hear that you it is working now!

From a quick inspection of the AccelStepper library I think it is unlikely that there would be any limitations for what pins you could use on the A-Star 328PB. (It seems like the library generates pulses on the STEP pin ultimately just by using the typical digitalWrite() and delayMicroseconds() Arduino functions.)

- Patrick

Cheers, thanks Patrick. Always greatly appreciate your expert help!

2 Likes