[Icc-430] Reading MSP-430 status register from C....
bailey at peak.org
bailey at peak.org
Fri Apr 11 11:32:57 PDT 2008
Jerry,
Now I'm sure I must be missing something. Your suggestion:
> DINT();
> asm("mov r2, &0x200");
> new_save = sr_copy;
> EINT();
doesn't seem like it would work since the _DINT(); would clear the GIE
bit I'm trying to read with the "mov"? And while you can use a _DINT();/
_EINT(); pair to protect critical sections, you had better make sure that
interrupts were enabled when the code was called, if not they will be
afterwards :)
Also, I don't think I can use different addresses to save the status
since the address is part of the function being called, not the function
doing the calling? If I pass the address in as a parameter then I'm back
to the compiler not having an available register to store it in...
Kirk
> 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
>
> _______________________________________________
> Icc-430 mailing list
> Icc-430 at imagecraft.com
> http://dragonsgate.net/mailman/listinfo/icc-430
>
More information about the Icc-430
mailing list