Info on timer interrupts for a port to Arduino Nano RP2040?



I'm trying to port OnStep to an Arduino Nano RP2040 Connect on a CNC V4 shield.  I have it running with only the timers to finish reimplementing in the HAL. Everything else (command line processing, PPS, GPS TLS, WiFi, etc..) is working.

Is there documentation on the role and intervals for timer1, timer 3 and timer4? The RP2040 has a funny implementation for its timers. There is only a 32-bit microsecond free running counter and the timer interrupts are programmed to trigger on a compare register to the micro-sec "clock". There are no pre-scalar or clock source selection. The RP2040 has a bunch of these timer compare registers but only two that are 32-bits.  

I'm using TMC2209 stepper drivers with 8 microsteps by grounding the M0 and M1 pins of the 2209 (The CNC V4 has jumpers to ground that can be used).  My mount is an EQ-3 and I had sidereal tracking and GoTo working with a regular Arduino Nano. I had stripped out most features and capabilities out of OnStep to get it to fit in the small memory of the Nano. I had also completely rewritten the timer and sidereal clock implementation to function on two timer interrupts (RA and DEC) of the Nano. My approach was for the Nano to keep track of sidereal time as an integer count of microsteps and the RA and DEC positions were computed as offsets from this sidereal microstep clock. It allowed the math to be all integer and clock accuracy was still possible with an external PPS used to adjust the RA timer interrupt interval. I then wrote an INDI mount driver that handled all the conversion from RA and DEC position in number of microsteps from the reference sidereal counter which allowed me to use PHD2 and Stellarium.

With the TMC2209, GoTos are ultra quiet as I had implemented a smooth acceleration and deceleration function.
It worked well for GoTo but guiding was not very successful. For Goto, I'm reimplementing on a Nano RP2040  because I want the full feature suite of OnStep and I'm not interested in troubleshooting the DEC guiding issues I had.

Any pointers to documentation on the RA,DEC and sidereal timer functions would be welcomed. Otherwise, I'll continue to reverse engineer my comprehension.



Join to automatically receive all group messages.