Issues with ATMega32PB?

22 views
Skip to first unread message

Ross Waddell

unread,
Nov 20, 2025, 3:23:08 PM (7 days ago) Nov 20
to accelstepper
I've had great success with this library running steppers in my models but now I've run into a roadblock using a Pololu A-Star 328pb Micro board - nothing happens! Not even a twitch. This code runs fine with other boards (and even ATTiny* chips) through a TMC2208 SilentStepStick driver board. I've double-checked the connections, and even tried some other pin assignments but no go. I searched "328pb" here and it doesn't seem like anyone else has this problem.

// A-Star 328PB Micro

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

#define EN_PIN          3     // LOW: Driver enabled. HIGH: Driver disabled
#define DIR_PIN         2    // 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         5    // To set step mode (pin A2)
#define MS2_PIN         6    // 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);
  digitalWrite(EN_PIN, HIGH);   // Disable driver in hardware

  pinMode(MS1_PIN, OUTPUT);
  pinMode(MS2_PIN, OUTPUT);

  // 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();
}

David Forrest

unread,
Nov 20, 2025, 3:53:34 PM (7 days ago) Nov 20
to accelstepper
These look suspicious:

```
#define STEP_PIN        4    // Step on rising edge (pin A1)
#define MS1_PIN         5    // To set step mode (pin A2)
#define MS2_PIN         6    // To set step mode (pin A3)
```
relative to the pinouts on: 


Are you sure 4 == A1?  In normal Arduino 328 code, A1 == 15, A2 == 16, and A3 == 17.

Ross Waddell

unread,
Nov 20, 2025, 4:02:45 PM (7 days ago) Nov 20
to accels...@googlegroups.com
Ignore the comments - they were for the original pin assignments.

--
You received this message because you are subscribed to the Google Groups "accelstepper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/accelstepper/631f98b4-a124-4240-9555-dde20ddd7a3dn%40googlegroups.com.

gjgsm...@gmail.com

unread,
Nov 20, 2025, 11:43:27 PM (7 days ago) Nov 20
to accelstepper
I'm not familiar with the  Pololu A-Star 328pb Micro board, the following is an AI response:

Response. (there was a lot more...)

The ATmega328PB is not a drop-in substitute for the ATmega328P, and the A-Star 328PB Micro’s Arduino core does not map its extra pins in the same way as the classic 328P boards. AccelStepper is sensitive to the low-level pin-toggling implementation, so if the pin mapping is wrong, the library will appear “dead” even though the code runs.


1. Wrong pin mapping on ATmega328PB

The Pololu A-Star 328PB Micro uses MegaCoreX or MiniCore 328PB pin definitions, not the standard Arduino Uno mappings.

Several of the pins used in your sketch:

DIR_PIN = 2

STEP_PIN = 4

EN_PIN = 3

MS1_PIN = 5

MS2_PIN = 6

are not actually mapped to the physical pins you think they are on the 328PB.


The ATmega328PB has duplicated ports (PORTC0, PORTC0′, etc.). Many Arduino cores expose only some of these, and some pins are remapped depending on which core you selected.

On 328PB boards, the Arduino pin numbers often do not correspond 1:1 with the Uno mapping.
AccelStepper toggles pins through fast I/O using those Arduino pin numbers, so if the mapping is wrong:

- STEP never toggles

- DIR never changes

- The driver sees nothing


Confirm exactly which Arduino core you selected:

- If using MiniCore, select:
   Tools → Board → ATmega328PB
   Tools → Pinout → “Standard”

 

- Then consult Pololu’s pinout for the A-Star 328PB Micro and update your STEP/DIR pins to ones that  actually map to hardware pins with correct I/O support.

 

Typical working pins on MiniCore 328PB:

STEP_PIN = 9   // OC1A, reliable high-speed toggle

DIR_PIN  = 8

EN_PIN   = 7

Your existing pins (2,3,4,5,6) are often remapped or duplicated and frequently do not behave as standard digital pins when the wrong core/pinout is selected.

Ross Waddell

unread,
Nov 21, 2025, 12:43:30 PM (6 days ago) Nov 21
to accels...@googlegroups.com
Pololu provides board mappings that you integrate into the Arduino IDE, and I know the digital pins used in my sketch work as I’ve tried the blink example on all of them.

a-star_328pb_micro_pinout.pdf

gjgsm...@gmail.com

unread,
Nov 21, 2025, 5:02:24 PM (6 days ago) Nov 21
to accelstepper
I copies and pasted your last post and pinout graphic to the AI and here is it's response:


If the blink test works on those pins, that only confirms the pins can toggle under digitalWrite(). AccelStepper does not use digitalWrite() for STEP-pin timing. It 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.

On the A-Star 328PB, Pololu’s board package exposes extra PB/PC/PE pins, but the Arduino core you compile with must also provide correct fast-I/O mappings for the 328PB variant. Several 328PB cores (including older Pololu ones) simply reuse the ATmega328P mapping. That works for blink, but it breaks AccelStepper because the 328PB has duplicated ports and a different pin map.

That’s why the motor works on other MCUs but shows “no twitch” on the 328PB.

Recommended fix

Use a core with correct 328PB pin definitions (e.g., MiniCore with ATmega328PB + Standard pinout) and move STEP/DIR to pins with stable mappings—PB0/B1 (Arduino 8/9) are the safest. With correct fast-I/O tables, AccelStepper immediately starts producing real STEP pulses.

Blink can still succeed while AccelStepper fails; the two do not use the same I/O layer.

Ross Waddell

unread,
Nov 21, 2025, 5:27:30 PM (6 days ago) Nov 21
to accels...@googlegroups.com
Wow, that really explains a lot and makes total sense - thanks! I do have MiniCore already when I was trying to texting a bare ATMega328PB chip.

I’ll try MiniCore and report back.

Ross Waddell

unread,
Nov 25, 2025, 3:28:51 PM (2 days ago) Nov 25
to accelstepper
So, I think the real issue here was a damaged current limiting pot on the TMC2208 SilentStepStick - it eventually just popped off. Once I swapped in another TMC2208 board this code works perfectly on the A*328PB Micro (programmed as that, NOT using MiniCore).

#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();
}
Reply all
Reply to author
Forward
0 new messages