Counter API Delay Accuracy on Ambiq Apollo3 with Zephyr #86820
Replies: 6 comments 6 replies
-
For the sake of completeness, below is my device tree:
|
Beta Was this translation helpful? Give feedback.
-
Have you checked the output of It could also be that the relative alarm is too short and by the time the alarm is set it could already be expired. Some drivers implement a late detection algorithm to handle such situations. |
Beta Was this translation helpful? Give feedback.
-
counter.c file :
and the main.c file:
|
Beta Was this translation helpful? Give feedback.
-
Based on my review of the Ambiq driver code, I observed the following implementation:
In this snippet, if the Given this behavior, my observation that a delay of 10 µs does not work as expected might be due to another factor in the system rather than the interpretation of the tick value. I would appreciate any further insights or suggestions regarding this issue. |
Beta Was this translation helpful? Give feedback.
-
I just realized that my callback function as an ISR won't be invoked if I set the delay below 20 µs, but I don't know why. |
Beta Was this translation helpful? Give feedback.
-
I have checked the driver code thoroughly, and it appears to be correct. However, whenever I configure the delay to 10 microseconds, the ISR does not trigger for reasons I do not fully understand. As my experience with Zephyr is limited, I would greatly appreciate any guidance or suggestions on how to resolve this issue. |
Beta Was this translation helpful? Give feedback.
-
I am facing an issue using the counter API for the Ambiq Apollo3. I have configured the device tree to use
counter0
with clock source 2 (CTIMER_CTRL0_TMRA0CLK_HFRC_DIV16
) and a frequency of3 MHz
. Theoretically, it should be possible to achieve an accuracy of approximately 334 ns. I used the counter sample code (Counter Sample Code) to implement a 10 µs delay, but the code does not work below 50 µs. However, delays of 50 µs and above work fine.I would appreciate it if someone could shed light on this problem, whether it is a bug in Zephyr, an issue with the implementation of the Ambiq driver, or if I made a mistake in my configuration.
Beta Was this translation helpful? Give feedback.
All reactions