[Icc-430] Reading MSP-430 status register from C....
bailey at peak.org
bailey at peak.org
Fri Apr 11 18:32:04 PDT 2008
Richard et al,
IAR provides a couple of ways to access SR. In looking at code around
the web that uses the various approaches it looks like implementing the
following two intrinsics covers the more common usage, and incidently,
functionally matches with the intrinics you already have:
unsigned short __get_SR_register(void);
Returns the current contents of SR.
unsigned short __get_SR_register_on_exit(void);
Returns the value SR will be set to on IRQ/monitor function exit. Same
idea as the _BIS_SR -vs- _BIS_SR_IRQ difference.
In looking at various code examples I couldn't find any popular
shorthand names for these critters as macros, but that is definitely less
important than providing the functionality! As a "variation", it looks
like some folks define the return values to be simple ints. I think they
should at least be unsigned, personally.
Kirk
> What's the name and effect of the IAR intrinsic?
>
> 1) doesn't work currently only because there's a bug in the asm
> inline expansion that it doesn't expand non-registered locals
> correctly. I will fix it.
>
> At 09:34 AM 4/11/2008, bailey at peak.org wrote:
>> Hi. I'm looking for suggestions of good ways to read the MSP-430
>>status register from within a function in C as part of an effort to
>>selectively disable/restore the GIE flag. I've played with various
>>approaches:
>>
>>1) Using inline asm ala: asm("mov r2,%saveSR")
>>
>>This doesn't work since the function it is called from is complex and the
>>compiler apparently can't free up a register to store the local variable
>>saveSR in.
>>
>>2) Use the "monitor" pragma on the function
>>
>>This doesn't work well since there are multiple sections of code in the
>>function that need protection (chained accesses to the HW multiplier),
>> and
>>turning interrupts off for the duration increases the latency to the
>> point
>>where I'm losing high speed interrupts.
>>
>>3) Use a simple function to read the value of the SR and return it.
>>
>>This works, but adds more overhead to the function execution than I like.
>>
>> So, anyone have another approach they like, or perhaps a clever way
>> of
>>implementing one of the above? (What I really need is an intrinsic ala
>>IAR, etc :)
>>
>
> // richard (This email is for mailing lists. To reach me directly,
> please use richard at imagecraft.com)
>
> _______________________________________________
> Icc-430 mailing list
> Icc-430 at imagecraft.com
> http://dragonsgate.net/mailman/listinfo/icc-430
>
More information about the Icc-430
mailing list