arduino / arduino/ArduinoCore-samd
Tone lower than ~40 Hz doesn't work
- Dominant language
- C
- Stars
- 502
- Forks
- 740
- PR merge metrics
- No merged PRs in 30d
Description
I see no technical reason why this shouldn't work.
Assuming the generic timer clock is 8MHz, then tone() should be able to support as low a frequency as .11Hz with a 16 bit timer by my calculation
(my goal is to use it to flash an LED 3 times in one second, but it doesn't seem to work on my Sparkfun Qwiic Micro which is a SAMD21 board).
As per the formula in the function, at 3Hz, (8E6/2)/3/(2^6) < 0xFFFF, so it should work right? Am I making a calculation error?
Side note (Potentially adding an overflow counter could be pretty useful for longer tone durations)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the tone() implementation and reviewing the frequency calculation for the SAMD21 timer below approximately 40 Hz, using the reported 3 Hz case and 8 MHz assumption as the first comparison. Done means tone() produces the requested low frequency on the reported board; the proposed overflow counter is a separate scope decision.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- arduino, c
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100