Roberto Padovani schrieb:
Ok. Then I'll add another def to my own collection. I think it's quite
useful to have something like:

__BIS_SR_reg2reg(x)    __asm__ __volatile__( "bis  %0, r2" : : "r"
((uint16_t)x) );

for example i use it in routines that cannot be interrupted, this way:

int_status = READ_SR & GIE;      // read status register and mask GIE
dint();                                          // ensure this
routine in unninterruptible
...
...stuff...
...
__BIS_SR_reg2reg(int_status)      //  = eint() if irqs were enabled

so that the interrupt status is unaltered at the end of the routine
and no test and jump is required.

you could also use the "critical" function attribute that is provided by mspgcc (which generates less code that your solution)

crititcal void some_function_with_disabled_interrupts(void) {}

chris

Reply via email to