2016-04-23 09:25 PM
Simple question
If I set some interrupts priorities to 0, should I expect time measurements (down to the microsecond) to be inaccurate? ( using SystemCoreClock and SysTick->VAL )2016-04-25 04:55 AM
Hi Zawyer,
The SysTick interrupt is an internal Cortex exception and is handled in the system registers. By default, it has a high priority than the other interrupt programmed by user ( as mentioned in the vector table in reference manual). So, you expect Systick interruption occurs without any preemptions (which may cause timing delay) if not reconfigured by user. -hannibal-Simple question
If I set some interrupts priorities to 0, should I expect time measurements (down to the microsecond) to be inaccurate? ( using SystemCoreClock and SysTick->VAL )2016-04-25 05:49 AM
Well the hardware timers/clocks are going to keep ticking regardless of what your interrupts do. The values you read from these registers will be the time when you actually do that.
If your interrupts are soaking up a lot of time, and distorting the measurements, then you need to review what you are doing. Again, as indicated before, don't confuse the priority level with the preemption level. If the SysTick interrupt, 1ms not 1us, is critical, it should preempt your other interrupt code. Review chapters on NVIC, and configuration of levels, and preempty vs priority.2016-04-25 05:52 AM
Think of changing priority as moving carriages on a train, you can change the order, but the end of one is connected to the front of the next.
Think of preemption as getting on the express train, it is a different train, with different carriages.2016-04-25 08:47 PM
If you have concerns about the accuracy of timers read during an interrupt, being affected by other competing interrupts, then you may be able to address the problem by using the original interrupt trigger source to instead trigger a DMA transaction that reads the timer value. The DMA won't be interfered with by the other interrupts because it works in parallel to the CPU, so it's timing won't be contaminated.
Re-reading my paragraph above, it sounds complicated, but it really isn't that bad :)2016-04-28 07:15 PM
Priorities, preemption, SysTick is independent, DMA possible approach for critical timing.
Got it. Thanks guys2016-04-28 07:37 PM
SysTick->VAL
The SysTick is 24-bit wide, often clocking at 1/8th the CPU rate, you can miss it wrapping. For critical timing I tend to prefer DWT->CYCCNT as it is 32-bit and clocks at the CPU rate. Wraps at about a minute on 72 MHz device.