flok
Well-known member
Hello,
I've connected a PPS (pulse per second, by using a GPS) source to a Teensy 4.1.
Then I measure the number of cycles (via ARM_DWT_CYCCNT) between each interrupt. I do that both in the interrupt handler and in "loop()".
The one in the loop-function produces an histogram that I expected:
one bump. Note that the x-axis is in nanoseconds with an offset (see the +9.9999e8). Y-axis is how often a measurement was seen. 50 bins.
If I do the same with the data from the interrupt-routine, I get:
My question now is, why are there 2 bumps?
The interrupt handler is:
The loop() function also uses delta_nanos_32 by the way.
[...]
Oh hang on, maybe it (the two bumps) is caused by the Ethernet interrupt. My goal was producing a simple time server so I enabled Ethernet. I'm now testing (will take a few hours) what the graph looks like with Ethernet disabled (I expected that the GPIO interrupt would have a higher prio than the Ethernet handling).
I've connected a PPS (pulse per second, by using a GPS) source to a Teensy 4.1.
Then I measure the number of cycles (via ARM_DWT_CYCCNT) between each interrupt. I do that both in the interrupt handler and in "loop()".
The one in the loop-function produces an histogram that I expected:
one bump. Note that the x-axis is in nanoseconds with an offset (see the +9.9999e8). Y-axis is how often a measurement was seen. 50 bins.
If I do the same with the data from the interrupt-routine, I get:
My question now is, why are there 2 bumps?
The interrupt handler is:
volatile uint32_t d = 0;
volatile uint64_t ts = 0;
uint32_t delta_nanos_32(uint32_t *const last) {
asm("dsb");
uint32_t c = ARM_DWT_CYCCNT;
uint32_t m = c;
c -= *last;
*last = m;
return c * 1000000000ULL / F_CPU;
}
void int_func() {
static uint32_t last = 0;
d = delta_nanos_32(&last);
ts = micros_64();
}
The loop() function also uses delta_nanos_32 by the way.
[...]
Oh hang on, maybe it (the two bumps) is caused by the Ethernet interrupt. My goal was producing a simple time server so I enabled Ethernet. I'm now testing (will take a few hours) what the graph looks like with Ethernet disabled (I expected that the GPIO interrupt would have a higher prio than the Ethernet handling).
Last edited: