Hi,
then i am starting the timer with configuration :
Hi,
then i am starting the timer with configuration :
I need to understand all the contexts in which you are doing this.
For me it seems more of the post processing latency issue when you are capturing the delta than the timer accuracy issue.
Can you give me a simplistic project to test?
Maybe it is post processing.
1. I started form EVENT_MANAGER project
2. I generate every 500 us timer event, then submit this event to two module that should process the data
3. Every 2000 samples (1 second) i print the delta of time now - previous time , so it should be 1 second.
If I were to perform a SPIM transaction exactly every 500 us, I would do the following.
- Use one RTC compare register that publishes a DPPI event.
- Use one TIMER peripheral configured to perform the START task when the DPPI event from RTC compare is triggered.
- Use a TIMER compare register, programmed with the < 31.518 microseconds adjustment needed to match 500 microseconds, that triggers a DPPI event. A "shortcut" is programmed as well to stop the TIMER at the same time.
- Program the SPIM peripheral to listen on the DPPI event from the TIMER to start the transaction.
- Use an interrupt on the END event from SPIM to process the data, set up for the next SPIM transaction as well as program the timing and DPPI as instructed above for the next transaction to be started at the correct time.
This method will use the sleep clock and thus very low power between the cpu finished processing the last SPIM transaction result until the RTC wakes up the TIMER.
Note that the RTC runs at an interval of 1/32768 seconds, which is around 30.518 microseconds. 500 is not divisible by this number, since 500/(1/32768) = 16.384. Therefore a TIMER peripheral must be configured to wait for the last microseconds, to make the result accurate. So, assuming the RTC is turned on all the time, in order to calculate the next rtc and timer compare registers, you need to take into account the previous TIMER peripheral adjustment (before the previous SPIM transaction) and the next TIMER peripheral adjustment (to be applied in the next SPIM transaction). If you are happy with, let's say, performing a SPIM transaction every ~488 or ~519 microseconds instead, you can use the RTC only and skip the TIMER.
Not sure how to program this with Zephyr in mind though, since I have not used Zephyr.
Hi,
I tested it without zephyr +/- like you suggested, it is working.
Looks like integrations with zephyr is the issue.
Did you try to use event manager?