[Icc-430] Reading MSP-430 status register from C....

bailey at peak.org bailey at peak.org
Fri Apr 11 22:11:16 PDT 2008


Hi,
    For the current issue I need to read the GIE bit, but there are other
situations where it is useful to be able to examine other status bits.

    Basically what I'm trying to do is implement two primitives:

1.  Enter-Monitor (read current GIE status, set GIE to 0)

    This primitive is where I need to be able to read the SR, followed by a
_DINT() /* or _BIC_SR(GIE) */.  Depending on the application it may also
be useful to isolate the GIE bit by itself in the saved copy to avoid
over-writing some of the other flags in the SR during the later execution
of the  "exit" primitive.

2.  Exit-Monitor (restore saved GIE status)

    This translates into a _BIS_SR(saved_GIE_status)

    As far as "my obsession with compiler register allocation", I'm
referring to the error message I get from ICC.  From Richard's earlier
response it sounds like it is a fixable compiler bug, which is encouraging!

    Kirk

.>>     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...
>
> Of what portion of the SR are you trying to make use?
>
> What is the obsession about the "compiler not having
> enough registers to store the result"?  Isn't register
> allocation the compiler's problem?
>
>
> _______________________________________________
> Icc-430 mailing list
> Icc-430 at imagecraft.com
> http://dragonsgate.net/mailman/listinfo/icc-430
>




More information about the Icc-430 mailing list