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.

CCS/MSP432P401R: Enabling/Disabling interrupts

Part Number: MSP432P401R

Tool/software: Code Composer Studio

I am in the process of Franken-combining two different examples and one uses:

MAP_Interrupt_enableMaster(); from DriverLib and the other uses:

 

__enable_interrupt();

 

Am I doing the same thing twice? Is there a difference between the two?

  • I think functionally these two both are about the same.  It would take me some more digging to find out if they are identical or not.  The __enable_interrupt() is an intrinsic function, you can view the assembly call in this document.

    The DriverLib function call can be found in cpu.c of the driverlib folders and appears to be a very similar call.  Below: First picture is from intrinsic; Second is from cpu.c function ultimately called by MAP_Interrupt_enableMaster();.  M4 cortex doesn't appear to match up as closely as expected, but there is likely a reason for that.

    Short answer: Yes, i believe they are functionally the same.  However, they aren't really interchangable without doing the proper includes/etc. So typically I would just stick with whichever implementation is used by example code from TI-REX when applicaple.

    Is this a suitable answer for you, or do you need this answer for something more complex?

  • Thanks. I am currently using both! 8^)

    /* Enabling interrupts */
    	MAP_UART_enableInterrupt(EUSCI_A0_BASE,
    	EUSCI_A_UART_RECEIVE_INTERRUPT | EUSCI_A_UART_TRANSMIT_INTERRUPT);
    	MAP_Interrupt_enableInterrupt(INT_EUSCIA0);
    	MAP_Interrupt_enableMaster();
    
    	/* Initialize the demo. */
    	boardInit();
    	clockInit();
    	initializeButtons();
    
    	/* Globally enable interrupts. */
    	__enable_interrupt();
    

    This is what happens when you try to combine two examples. I am asking because I want to turn off interrupts in a portion of my serial receive code and was just wondering about the difference, I suspect that driverlib eventually calls __enable_interrupt();

  • The DriverLib one doesn't call the intrinsic directly, but the asm of the intrinsic is almost identical to that of the DriverLib function.

    It shouldn't hurt to have both, but I think you only need one.  Since you are using DriverLib functions anyways, my suggestion is the DriverLib one.  Was there an example where you saw it used like this or did you just decide to do it this way for another reason?  (Also, I tested a few of the DriverLib examples earlier just to see what would happen without the call.  The ones I tried still function properly, implying functions like UART_enableInterrupt might also be enabling the master interrupt.  But good to keep that at least for redundency I guess.)

  • The k3500 grlib example does this:

    /* Initialize the demo. */
        boardInit();
        clockInit();
        initializeDemoButtons();
    
        /* Globally enable interrupts. */
        __enable_interrupt();
    
    

    And the Driver lib UART echo example does this:

    /* Enabling interrupts */
        MAP_UART_enableInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_RECEIVE_INTERRUPT);
        MAP_Interrupt_enableInterrupt(INT_EUSCIA0);
        MAP_Interrupt_enableSleepOnIsrExit();
        MAP_Interrupt_enableMaster();   

    Since I wanted UART communication from my grlib program, I combined the two. Strangely, the other UART example does *not* use enableMaster().

  • Ok, that makes sense!

    I think you can do without using both, (or very likely without either since some redundancy seems to be built in already). 

    I think you can go without __enable_interrupts(); but I do not see any harm leaving it in (minimal code size or processing added due to this, in my opinion.)

**Attention** This is a public forum