L
Lasse Langwadt Christensen
Guest
søndag den 15. januar 2023 kl. 15.10.17 UTC+1 skrev Dimiter Popoff:
eight and usually in parallel with the fetch of the ISR address and instructions
so with overhead 12 cycles from interrupt to first instruction of the ISR is executed
\"good\" depending of what your objective is, automatic stacking save code space
and the time it takes to fetch that code
we are talking cortex-m with no real caches. The pico has a special cache to
run code directly from slow external serial flash resonable speed, but you can
tell the compiler to copy and keep a function in ram
On 1/15/2023 12:48, Lasse Langwadt Christensen wrote:
søndag den 15. januar 2023 kl. 06.10.24 UTC+1 skrev upsid...@downunder.com:
On Sat, 14 Jan 2023 04:47:22 GMT, Jan Panteltje
pNaonSt...@yahoo.com> wrote:
On a sunny day (Fri, 13 Jan 2023 15:46:16 -0800) it happened John Larkin
jla...@highlandSNIPMEtechnology.com> wrote in
q5p3shh8f34tt34ka...@4ax.com>:
What\'s the fastest periodic IRQ that you have ever run?
We have one board with 12 isolated LPC1758 ARMs. Each gets interrupted
by its on-chip ADC at 100 KHz and does a bunch of filtering and runs a
PID loop, which outputs to the on-chip DAC. We cranked the CPU clock
down some to save power, so the ISR runs for about 7 usec max.
I ask because if I use a Pi Pico on some new projects, it has a
dual-core 133 MHz CPU, and one core may have enough compute power that
we wouldn\'t need an FPGA in a lot of cases. Might even do DDS in
software.
RP2040 floating point is tempting but probably too slow for control
use. Things seem to take 50 or maybe 100 us. Back to scaled integers,
I guess.
I was also thinking that we could make a 2 or 3-bit DAC with a few
resistors. The IRQ could load that at various places and a scope would
trace execution. That would look cool. On the 1758 thing we brought
out a single bit to a test point and raised that during the ISR so we
could see ISR execution time on a scope. My c guy didn\'t believe that
a useful ISR could run at 100K and had no idea what execution time
might be.
Well in that sort of thing you need to think in asm, instruction times,
but I have no experience with the RP2040, and little with ASM on ARM.
Should be simple to test how long the C code takes, do you have an RP2040?
Playing with one would be a good starting point.
Should I get one? Was thinking just for fun...
In the past coding ISRs in assembly was the way to go, but the
complexity of current processors (cache, pipelining) makes it hard to
beat a _good_ compiler.
The main principle still is to minimize the number of registers saved
at
interrupt entry (and restored at exit).On a primitive processor only
the processor status word and program counter needs to be saved (and
restored). Additional registers may need to be saved(restored if the
ISR uses them.
If the processor has separate FP registers and/or separate FP status
words, avoid using FP registers in ISRs.
Some compilers may have \"interrupt\" keywords or similar extensions and
the compiler knows which registers need to be saved in the ISR. To
help the compiler, include all functions that are called by the ISR in
the same module(preferably in-lined) prior to the ISR, so that the
compiler knows what needs to be saved. Do not call external library
routines from ISR, since the compiler doesn\'t know which registers
need to be saved and saves all.
cortex-m automatically stack the registers needed to call a regular C function
and if it has an FPU it supports \"lazy stacking\" which means it keeps track of
whether the FPU is used and only stack/un-stack them when they are used
it also knows that if another interrupt is pending at ISR exit is doesn\'t need to
to un-stack/stack before calling the other interrupt
How many registers does it stack automatically?
eight and usually in parallel with the fetch of the ISR address and instructions
so with overhead 12 cycles from interrupt to first instruction of the ISR is executed
I knew the HLL nonsense
would catch up with CPU design eventually. Good CPU design still means
load/store machines, stacking *nothing* at IRQ, just saving PC and CCR
to special purpose regs which can be stacked as needed by the IRQ
routine, along with registers to be used in it.
\"good\" depending of what your objective is, automatic stacking save code space
and the time it takes to fetch that code
Memory accesses are
the bottleneck, and with HLL code being bloated as it is chances
are some cache will have to be flushed to make room for stacking.
Some *really* well designed for control applications processors allow
you to lock a part of the cache but I doubt ARM have that, they seem to
have gone the way \"make programming a two click job\" to target a
wider audience.
we are talking cortex-m with no real caches. The pico has a special cache to
run code directly from slow external serial flash resonable speed, but you can
tell the compiler to copy and keep a function in ram