You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6337083
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+38-2Lines changed: 38 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ Arduino core 3.1.0 will support ESP-IDF V5.3.0 (based on RC1)
21
21
## Overview
22
22
23
23
This is a high speed alternative for the [AccelStepper library](http://www.airspayce.com/mikem/arduino/AccelStepper/).
24
-
Supported are avr (ATmega 168/328/P, ATmega2560, ATmega32u4), atmelsam due, esp32, esp32s2, esp32s3, esp32c3, esp32c6, esp32p4, Raspberry pi pico and pico2.
24
+
Supported are avr (ATmega 168/328/P, ATmega2560, ATmega32u4), atmelsam due, Microchip SAMD51, esp32, esp32s2, esp32s3, esp32c3, esp32c6, esp32p4, Raspberry pi pico and pico2.
25
25
26
26
For memory footprint information across supported architectures, see [Memory Report](https://github.com/gin66/FastAccelStepper/blob/master/extras/doc/memory_report.md).
27
27
@@ -36,6 +36,7 @@ The stepper motors should be connected via a driver IC (like A4988) with a 1, 2
36
36
* I2S Direct mode: 1-3 additional steppers using I2S controllers directly (IDF ≥5.3)
37
37
- pico: Any GPIO up to 31
38
38
- atmel sam due: This can be one of each group of pins: 34/67/74/35, 17/36/72/37/42, 40/64/69/41, 9, 8/44, 7/45, 6
39
+
- samd51: Any pin with a TCC waveform output in the board's variant table (checked at `stepperConnectToPin()`), one stepper per TCC instance
39
40
- Step should be done on transition Low to High. High time will be only a few us.
40
41
On esp32 the high time is for slow speed fixed to ~2ms and high speed to 50% duty cycle.
41
42
For pico direction delay is recommended
@@ -55,7 +56,7 @@ FastAccelStepper offers the following features:
55
56
* 1-pin operation for e.g. peristaltic pump => only positive move
56
57
* 2-pin operation for e.g. axis control
57
58
* 3-pin operation to reduce power dissipation of driver/stepper
58
-
* Lower limit of 260s per step @ 16MHz aka one step every four minute (esp32/avr), 198s for sam due
59
+
* Lower limit of 260s per step @ 16MHz aka one step every four minute (esp32/avr/samd51), 198s for sam due
59
60
* fully interrupt/task driven - no periodic function to be called from application loop
60
61
* supports acceleration and deceleration with per stepper max speed/acceleration
61
62
* Allows the motor to continuously run in the current direction until stopMove() is called.
@@ -94,6 +95,7 @@ The `src/` directory is organized into the following subdirectories:
94
95
|`pd_esp32/`| ESP32 pulse driver: RMT, MCPWM/PCNT, and I2S-based stepper control |
95
96
|`pd_pico/`| RP2040/RP2350 pulse driver: PIO-based stepper control |
96
97
|`pd_sam/`| SAM Due pulse driver: timer-based stepper control |
98
+
|`pd_samd/`| SAMD51 pulse driver: TCC PWM-based stepper control |
97
99
|`pd_test/`| Test platform pulse driver: PC-based testing simulation |
@@ -276,6 +278,15 @@ This test application was AI crafted....
276
278
277
279
Tested with max two stepper motors with 50 kHz step rate by clazarowitz
278
280
281
+
### Microchip SAMD51
282
+
283
+
* one stepper per TCC instance: 3 steppers on SAMD51G, up to 5 on SAMD51J/N/P
284
+
* step pin must have a TCC waveform output in the board's variant table; direction/enable can be any output pin
285
+
* one overflow interrupt per step; pulse edges are hardware-timed, so step timing is exact regardless of interrupt latency
286
+
* Steppers' command queue depth: 32
287
+
* SAMD21 is not supported (compile error)
288
+
* requires an Arduino SAMD51 core (uses the variant pin table); tested with the Adafruit SAMD core
289
+
279
290
## Usage
280
291
281
292
The library is in use with A4988, but other driver ICs should work, too.
@@ -492,6 +503,30 @@ This is supported by clazarowitz
492
503
493
504
**Note:** The SAM platform cannot be tested in CI. An audit against the SAM3X8E datasheet has identified [6 open issues](https://github.com/gin66/FastAccelStepper/blob/master/extras/doc/ai_improvements/05_sam_platform_audit.md) (4 critical, 2 minor), including invalid pin mappings and a wrong timer register value. Any changes to the SAM code must be cross-checked against that document.
494
505
506
+
### Microchip SAMD51
507
+
508
+
The step pin's TCC runs in normal PWM mode with buffered registers: `PERBUF` holds the next
509
+
step interval and `CCBUF` the pulse width, so pulse edges are generated by hardware and are
510
+
tick-exact regardless of interrupt latency. One overflow interrupt per step decrements the
511
+
current queue entry and stages the next command at command boundaries — the same design as
512
+
the AVR port, but with the timer's double buffering removing the edge-timing race.
513
+
514
+
The timebase is exactly 16 MHz (DFLL48M divided by 3) on a dedicated generic clock
515
+
generator, matching the AVR/ESP32/Pico tick rate so the precomputed ramp constants apply.
516
+
The ~4 ms ramp tick (`manageSteppers()`) runs from a plain TC instance. Defaults can be
517
+
overridden at compile time if your project claims these peripherals:
518
+
519
+
```
520
+
-DFAS_SAMD_GCLK_GEN=6 // generic clock generator for the 16 MHz timebase
521
+
-DFAS_SAMD_RAMP_TC=3 // TC instance for the ramp tick (TC0 is used by tone())
522
+
-DFAS_SAMD_PULSE_WIDTH_US=2 // step pulse high time
523
+
```
524
+
525
+
The implementation contains a workaround for silicon erratum DS80000748 (2.20.1): clearing
526
+
`STATUS.PERBUFV`/`CCBUFV` releases SYNCBUSY before the buffer registers are actually
527
+
restored, so the flags are cleared twice with SYNCBUSY waits — otherwise a write to `PER`
528
+
right after an aborted buffered update can wedge the synchronization bridge permanently.
529
+
495
530
### ALL
496
531
497
532
The used formula is just s = 1/2 * a * t² = v² / (2 a) with s = steps, a = acceleration, v = speed and t = time. In order to determine the speed for a given step, the calculation is v = sqrt(2 * a * s). The performed square root is an 8 bit table lookup using log2/pow2. Sufficient exact for this purpose.
@@ -656,4 +691,5 @@ As mentioned by kthod861 in [Issue #110](https://github.com/gin66/FastAccelStepp
656
691
- Thanks Magnus for pico sdk support and code improvement hints (#334)
657
692
- Thanks Sam W for pull request (https://github.com/gin66/FastAccelStepper/pull/351) samx3-due: Fix null result from `tryAllocateQueue()`
658
693
- Thanks drayde for pull request (https://github.com/gin66/FastAccelStepper/pull/366) Fix ESP-IDF 6 RMT header include
694
+
- Thanks Loriland for the Microchip SAMD51 port (https://github.com/gin66/FastAccelStepper/issues/317)
0 commit comments