[Icc-430] Reading MSP-430 status register from C....
Jerry Durand
jdurand at interstellar.com
Fri Apr 11 11:11:05 PDT 2008
At 10:55 AM 4/11/2008, bailey at peak.org wrote:
>Jerry,
> Thanks for the suggestion. The only problem that I see is that the
>function in question can be called both from the background and a couple
>of interrupt routines. Having a single location for the saved status seems
>destined to lead to a corrupted saved interrupt status when an interrupt
>(that also calls the function), occurs between when:
>
>asm("mov r2, &0x200");
>
>gets executed and the following _DINT(); that disables the interrupts.
Then, use two different saved locations (0x200, 0x202). In the
interrupt use a different location.
> In the (more), common case where the function only got called from a
>single thread I think your idea should work. Am I understanding your
>approach correctly?
Note that 16 bit moves will NOT be interrupted in the middle. The
entire move will happen or not. 32 bit and larger moves CAN be
interrupted. If there's a chance of the interrupt changing your data
in the middle of a move, disable the interrupt.
Be liberal with DINT() and EINT() calls.
DINT();
asm("mov r2, &0x200");
new_save = sr_copy;
EINT();
I use this all the time when touching long counters used for the time
of day or changing settings for something the interrupt is
doing. Just don't leave the interrupts off for very long.
// global definition
ulong RTC; // updated in Salvo tick
int Do_Something(void) {
ulong time; // local variable
DINT();
time = RTC;
EINT();
if(time == 42424242L) {
return TRUE;
}
return FALSE;
}
--
Jerry Durand, Durand Interstellar, Inc. www.interstellar.com
tel: +1 408 356-3886, USA toll free: 1 866 356-3886
Skype: jerrydurand
More information about the Icc-430
mailing list