"Semaphore" with thumb code

OP #1174585
Rate this post
useful
not useful
Hello,

I have a following situation with Yagarto and AT91SAM7X:

Interrupt routine counts interrupts;

...
++signals;
...

In main loop, I need to do further processing based
on received signals (I want to keep interrupts lightweight,
so only minimal amount of work should be done there)

...
somevalue = signals*somescaler;
signals = 0;
...


Now, this is very thread-unsafe. But how can I do this safely with thumb
instruction set? No swp in thumb set, and load/store combination isn't
very atomic, and  the disabling interrupts apparently is troublesome
too:

I understood that disabling interrupts with AIC_IECR->IDCR causes
spurious interrupts, but could that really cause extra interrupts (ISR
called twice if it triggers at bad moment) or does that interrupt just
get served late? ISR getting server late would be no problem, since I
can do necessary processing fast enough to not miss interrupts, but how
is the situation exactly?

Now, another thing that isn't clear to me is thumb-interwork -mode. In
which situations that is needed exactly? For practical example, if I
have for example thumb module calling ARM (to access that precious swp
for example), how should I do that?
Non-interwork thumb-module calls interwork-thumb module that calls ARM
module, or how? (that single swp or access to global interrupt flag gets
really expensive really fast this way...)

Reply

Please log in before posting.

or

Log in with Google account

Registration is free and takes only a minute.

Register now