nrfx: drivers: nrfx_grtc: Improvements to speed up nrf_grtc_timer #288
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Set of proposed improvements to reduce time spent in the GRTC functions. The main factor impacting performance is the number of register accesses. For example on nrf54h20 each register access to GRTC takes ~0.5 us which is 160 cycles at 320 MHz.
Following improvements are proposed:
nrf_grtc_timer
that will speed up CC configuration.Newly added functons:
nrfx_grtc_channel_cb_alloc
Allocated a channel, enables interrupt source and stores callback + p_context. Previously only channel was allocated and enabling interrupt and storing callback+p_context was done on every new CC value setting. Those operations were redundant.nrfx_grtc_syscounter_cc_abs_set
- Function for setting absolute CC value. One of the parameters issafe_setting
bool. If true then it indicates that previous CC is earlier than new CC and it is not far in the future so longer and safer procedure must be applied. If false then CC can be just written with the new value.nrfx_grtc_syscounter_cc_rel_set
- Function for setting CCADD. It just writes CCADD. It is caller responsibility to use it only when it makes sense. Fornrf_grtc_timer
it is used when setting a new CC value from callback of previous Compare event. It is using relative to CC.Modified function:
nrfx_grtc_syscounter_start
- Addedhandler
andp_context
to function parameters. It not only allocates main channel but stores callback and enables interrupt handler.