gin66 / FastAccelStepper

A high speed stepper library for Atmega 168/328p (nano), Atmega32u4, Atmega 2560, ESP32, ESP32S2, ESP32S3, ESP32C3, ESP32C6 and Atmel SAM Due
MIT License
314 stars 72 forks source link

Arduino Nano Every support #123

Open KyleLomen opened 2 years ago

KyleLomen commented 2 years ago

Are there any plans to support the Arduino Nano Every? I just got one and was annoyed that FastAccelStepper doesn't work on it (I somehow did not notice that it uses a different processor from the Arduino Nano). From the quick research that I did, it will not be an easy change as the architecture is very different.

It uses the ATMega4809 (megaAVR architecture) and assuming that I understand the datasheet correctly, it has 1 "type A" and 4 "type B" timers. The Arduino Core seems to use the "type A" and 2 of the "type B" timers for PWM, but it also might use the other "type B" timers for something else? The code is not clear. The timer can generate an "event" that can trigger the MUX to control an output pin, the available output pins for the events are: PA2 (A4), PA7 (none), PB2 (D5), PC2 (none), PC7 (none), PD2 (A1), PD7 (none), PE2 (D13), PF2 (also A4?).

The more I look into this, the more it seems like a huge process and I would not know where to start. Perhaps this might help someone else in the future.

gin66 commented 2 years ago

I have created a branch for AVRmega4809, which does not compile. The hope was, that the Timer type A is similar enough to the AVRs. But even, if the module is similar, the register/bit naming does not fit. So it will need much more time to get it going and ideally a board, too. Both I do not have and simavr apparently does not support that device, too. So in the near future, I cannot provide AVRmega4809 support. Sorry for this.

If someone likes to work on that port, then this branch is a good start. What needs to be done:

From what I have seen, the arduino core uses Timer type A only for analogwrite and only if the corresponding pins are in use. Curious, what the core uses as timebase.