Hi nRF support team,
What do I need to do if I want to use the precise delay of NS, now the delay error is very large.
thanks
Hi nRF support team,
What do I need to do if I want to use the precise delay of NS, now the delay error is very large.
thanks
Hi
You get the most accurate timing by running a TIMER peripheral with prescaler 0. Then you get a timer frequency of 16MHz, which equals an interval of 62.5ns.
What kind of accuracy do you need?
If you are triggering a measurement from the software keep in mind that your code might be interrupted by other parts of the system.
If you want to measure hardware events you can use the PPI controller to connect the hardware events to the timer directly, which ensures much more consistent timing.
Best regards
Torbjørn
Hi
You get the most accurate timing by running a TIMER peripheral with prescaler 0. Then you get a timer frequency of 16MHz, which equals an interval of 62.5ns.
What kind of accuracy do you need?
If you are triggering a measurement from the software keep in mind that your code might be interrupted by other parts of the system.
If you want to measure hardware events you can use the PPI controller to connect the hardware events to the timer directly, which ensures much more consistent timing.
Best regards
Torbjørn
Hi,Torbjørn
Thank you for your reply
I need the software to measure, and the delay accuracy is around 1us. Do you have the peripheral example of Timer? I am a novice, and I don't know how to configure it
thanks
Hi
Since you are using NCS and Zephyr it is possible to make accurate timing measurements by reading the system clock directly, like described here:
https://developer.nordicsemi.com/nRF_Connect_SDK/doc/0.3.0/zephyr/kernel/timing/clocks.html#measuring-time-with-high-precision
Can you try this method and see if it give you satisfactory results?
Best regards
Torbjørn
Hi,Torbjorn
Thank you for your reply
I have solved the problem of precise delay, but I have a new problem.
I have a piece of code that doesn't need any external interrupts or events to interrupt, but I use the __disable_irq() function before that and then __enable_irq() function after that. But it did not achieve the desired effect. If I don't call __enable_irq() the effect of turning on interrupts is what I want
1. Is there a problem with the __disable_irq() function? Why does closing interrupt and then opening interrupt affect the code in the middle? Is there any task or interrupt not closed successfully?
2. Does my problem have something to do with the frequent switching of the interrupt switch? If so, how do I fix it?
I am looking forward to your reply. This question is urgent
Thank you very much
Hi
What about using irq_enable() or irq_disable() instead?
These are the standard Zephyr functions for enabling and disabling interrupts:
https://docs.zephyrproject.org/latest/reference/kernel/other/interrupts.html
If this doesn't work, can you show me the code that is not behaving correctly?
Best regards
Torbjørn
Hi
Torbjørn
Here's my code:

Since I was using NCS 1.6.0, I replaced it with irq_lock(). Through the for (I = 0; i<200; I++) to flip the IO port, but the waveform seen with the oscilloscope is unstable. If only irq_lock() is executed and irq_unlock() is not executed, then the waveform is normal. The next two videos are my waveforms.
May I ask what causes this? Looking forward to your reply
Thank you very much