Forum : ST7/STM8
Original Post
    | Post Information | Post | 
|---|---|
| 
               September 21, 2010 - 10:18am 
             | 
                      
               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  | 
                  
            
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,