Issue with the latency measurements

Issue with the latency measurements

by Sylvain Jean-Roger Migaud -
Number of replies: 3

Hi,

I don't have access to a logic analyzer and I'm trying to do the latency measurements. I was trying to use the counter start it and trigger an interrupt with it then stop the counter in the interrupt handler in C to begin with.

To do that I just added this line "IOWR(0x40800, 3, 0x0000FFFF);" at the beginning of the "alt_irq_handler.c" file in the "alt_irq_handler" function

However, it just makes the program on the NIOS crash.

When I move this line lower in the function (last line for example) the program runs fine on the NIOS but it doesn't stop the counter.

Do you have an idea of why it isn't possible to use this function in the interrupt service routine ?

(I added io.h to the included files in the alt_irq_handler includes)


Also, I'd like to valide my current results if possible before going forward, in order of magnitude, does a response time of 261 clock cycles makes sense on a NiosII/f (running the timer, triggering an interrupt at 0, reading the value once in the interrupt function and printing it in the main code)

For the recovery time I have a delay of 162 clock cycles (I am starting the timer in the interruption and reading the value as soon as I reach the main code)

I guess the point of the lab is not to have exactly the same value as the correction as it depends on the overhead of the various methods used but rather to compare the effect of the different cache types but I'm still concerned since my values are higher than the one we have on the course slide

Thanks for your time,

Regards,

Sylvain


In reply to Sylvain Jean-Roger Migaud

Re: Issue with the latency measurements

by René Beuchat -

If you can put a breakpoint in your entry point, then look at the assembly level code, you will certainly see that some registers are used to calculate your address, and that you do that before any registers are saved on the stack. Then you will probably crash for that.

Why are you using absolute address to access your register in your counter and not the symbol from system.h?

Your counter is on 32 bits? as your are using the old unsupported IO_RD and IO_WR macro, it's mandatory to have a 32 bits bus.

Good luck.

RB

In reply to René Beuchat

Re: Issue with the latency measurements

by Sylvain Jean-Roger Migaud -

Hi,

Thanks a lot !

That was exactly my issue, I was confused as the code was separated into two distinct projects for the bsp (with th interrupt handler) and the main loop code (with the system.h)  and i didn't wanted to call unset variables but it turns out, both projects are sharing the system.h file !

Now it works, Thanks a lot !

With both data and instruction cache i get a value of 41 clock cycles, does it seems realistic to you (or at least coherent with my previous values and the method used) ?

Regards,

Sylvain


In reply to Sylvain Jean-Roger Migaud

Re: Issue with the latency measurements

by Sahand Kashani-Akhavan -
I did this measurement a long time ago, but I had measured 0.3 us for the interrupt latency, which corresponds to roughly 14 clock cycles. But I put a stwio instruction to a GPIO directly in assembly as the first instruction under the "alt_irq_entry:" label. Depending on how far in the code you inserted your latency measuring code, it's possible that 41 cycles is what you measure. It's in the right ball-park range.