https://github.com/charkster/samd21-32bit-timer
SAMD21 32bit Timer
https://github.com/charkster/samd21-32bit-timer
arduino gpio samd21 seeeduino-samd timer trinket-m0
Last synced: about 2 months ago
JSON representation
SAMD21 32bit Timer
- Host: GitHub
- URL: https://github.com/charkster/samd21-32bit-timer
- Owner: charkster
- License: mit
- Created: 2020-09-14T00:07:04.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-10-22T23:37:10.000Z (over 2 years ago)
- Last Synced: 2025-01-13T19:26:56.487Z (4 months ago)
- Topics: arduino, gpio, samd21, seeeduino-samd, timer, trinket-m0
- Language: C++
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
SAMD21 32bit timer.
This arduino program will enable a 32bit timer on a SAMD21 by combining TC Counters 4 & 5.
The SAMD21 is configured to load the CC0 and CC1 with pulse and period measurements from a single pin.
My purpose for creating this was to trim oscillators and measure longer durations.
This arduino file will work on both the Seeeduino XIAO and Adafruit Trinket M0 (tested on both).
Once programmed a serial port needs to be opened to the device before the measurement is made.
An optional delay is included after a single period has been measured (as to not overwhelm the serial port).I highly recommend the Seeedino Xiao over the Trinket M0 as it is cheaper and has more pins.
I'm not a big fan of the USB C connector on the Xiao (I prefer the Trinket M0's micro USB), as I needed to buy more C type cables.
My Seedino Xiao spends most of the time connected to my Raspberry Pi (as the Pi does not have any real-time measuring capability).Why use a 32bit timer instead of a 16bit one? A 32bit timer can measure a period/pulse of 89.5 seconds at maximum precision without overflowing ( 20.8ns * 2 ^ 32 ).
What can a 16bit timer measure (without overflowing, at maximum precision)... 1.36 milliseconds.There is no license for this work, it is use-at-your-own-risk (I assume no liability).
Many parts of this program came from on-line forums. I included the URLs in the program header to give credit.