Topic : Getting and setting interrupt state

Forum : ST7/STM8

Original Post
Post Information Post
September 21, 2010 - 10:18am
Guest

Hi,

In critical functions instead of using "disableInterrupts()" and then "enableInterrupts()" functions, some compilers offer functions like "get_interrupt_state()" and "set_interrupt_state()". Does the Raisonance STM8 compiler have some functions like these?

Thanks&Regards

Replies
Post Information Post
+1
0
-1
September 21, 2010 - 11:12am
Raisonance Support Team

Hi Volkan,

Yes, you can get the current STM8 interrupt state through the intrinsic functions, as in the following example shows:


#include     // RCSTM8 intrinsic functions definitions
#include 

void showinterrupts(void)
{
    char CCflags = _getCC_();

    printf("CC is 0x%02X\n", CCflags);
}


void main(void)
{
    _sim_();            // Disable interrupts
    showinterrupts();
    _rim_();            // Re-enable interrupts
    showinterrupts();

    while(1);
}

You can freely manipulate the contents of the CC registers once you retrieve it through the _getCC_ intrinsic function.

Note that the printf/putchar functions are reentrant, interruptible and can be used even if the interrupts are disabled, as putchar() is using a polling mechanism that does not require any interrupt.

Regards,