This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/CC430F5135: Is the msp430-gcc ISR critical attribute redundant?

Part Number: CC430F5135

Tool/software: TI C/C++ Compiler

In section 7.2 of the MSP430 GCC User's Guide (Rev. C), there is a "critical" attribute that is documented as "Disable interrupts on entry, and restore the previous interrupt state on exit." When I compile an ISR with this attribute, it adds a push r2; dint; nop to the beginning of the ISR and additional instructions at the end to undo this.

However, in Section 1.3.4.1 Interrupt Acceptance in the MSP430x5xx Family User's Guide (Rev. Q), it specifies that before entry into the user ISR, "3. The SR is pushed onto the stack." Further, "6. All bits of SR are cleared except SCG0, thereby terminating any low-power mode. Because the GIE bit is cleared, further interrupts are disabled."

This makes the critical attribute in MSP430 GCC seem redundant. Can someone explain this redundancy here? When should I ever mark a ISR critical?

  • I don't know.  So, I filed the entry MSPGCC-93 in the SDOWP system.  You are welcome to follow this entry with the SDOWP link below in my signature.  This should either result in the critical attribute being removed, or an explanation given as to when it is useful.

    Thanks and regards,

    -George

  • Thanks for taking a look, George. I can't find MSPGCC-93 once I follow the link to the 'readonly' SDOWP even after using the 'Search by ID' field. Could you provide a direct link?
  • It takes a few hours for a new entry to propagate through the system.  Please try again later.

    Thanks and regards,

    -George

  • Has any progress been made on this issue? I don't see any updates in SDOWP.
  • Since the MSP430 hardware handles interrupt acceptance (pushing the PC, SR to stack, clearing the SR) and interrupt return (popping the PC, SR from stack, restoring interrupt state), software instructions to perform
    these tasks are not necessary when an ISR has been registered in the interrupt vector table.

    However, if there is a need for a regular function to not be interrupted, it can be marked with the critical attribute, to disable interrupts on entry and restore the previous interrupt state on exit.

    But you are correct that the use of the critical attribute is redundant on a function already marked with the interrupt attribute. GCC should at least warn and probably disallow these attributes being used together.