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.

MSP430 LPM mode exit on TI-RTOS

Other Parts Discussed in Thread: SYSBIOS

Hi,

I'm using TI-RTOS on the MSP430. I would like to put my MSP430 in LPM4 mode then using an interrupt to return in normal mode.

To do that I wanted to use the function __bis_SR_register(LPM4_bits) to put my register in LPM4 mode and __bic_SR_register_on_exit(LPM4_bits) to return.

I'am using the HWI module in my configuration file. So the hardware interrupt routine are generated by SYS/BIOS in the HWIfunc.c with the function added in my configuration.

This my code :

Void ti_sysbios_family_msp430_Hwi32_p2(Void)
{
    ti_sysbios_BIOS_ThreadType prevThreadType;
    UInt swiKey;

    /* disable Swi scheduler */
    swiKey = ti_sysbios_knl_Swi_disable();

    /* set thread type to Hwi */
    prevThreadType = ti_sysbios_BIOS_setThreadType(ti_sysbios_BIOS_ThreadType_Hwi);

    /* run ISR function */
    HWI_IsrPortP4(0);

    /* run any posted Swis */
    ti_sysbios_knl_Swi_restoreHwi(swiKey);

    /* restore thread type */
    ti_sysbios_BIOS_setThreadType(prevThreadType);

}

Void HWI_IsrPortP4(Void)
{

    __bic_SR_register_on_exit(LPM4_bits);
    // Clear the interrupt to avoid another interrupt
    GPIO_clearInt(MSP_EXP430FR5969LP_S2);

    // Disable the interrupt to avoid the rebond
    GPIO_disableInt(MSP_EXP430FR5969LP_S2);

    // Send the semaphore to the keyboard task to indicate a push/release on S2
    Semaphore_post(SEM_InterruptS2);
}

This create an error because the function __bic_SR_register_on_exit can be call only in interrupt routine...

If I add __interrupt in my declaration (like this __interrupt Void HWI_IsrPortP4(Void)) There is another way?

Can I use the LPM4 mode in debug ?

  • Hi,

    I'm trying to understand the functions above. So 'ti_sysbios_family_msp430_Hwi32_p2' is a TIRTOS that was generated correct?

    You said this creates an error...Can you explain a bit more about the error, because your ISR is being called interrupt context.

    I'll look into the __interrupt declaration but I know that you can't use any interrupt declaration and have this be a Hwi.
    I think what you might need to do is have this be an ISR that does not go through the Hwi dispatch code.

    Judah
  • Julien,

    There are a couple of ways  to keep the CPU awake on exit from your ISR (and not return to LPM4): 1) You can enable this for all Hwi interrupts, or you can enable it for individual interrupts.  There is some description of this on this wiki page: processors.wiki.ti.com/.../BIOS_for_the_MSP430

    If you want this behavior for all interrupts, use the Hwi-module level “alwaysWake” configuration parameter.  You can do this in the graphical tool (by clicking the box “Always keep CPU awake”), or directly by editing the .cfg file, adding “Hwi.alwaysWake = true;”.

    Similarly, for an individual interrupt, in the GUI click the “Enable keep awake” box for the interrupt instance.  Or you can specify the Hwi parameter before calling create in the .cfg file (“hwiParams.keepAwakeEnabled = true;”).

    In either case, this will cause a __bis_SR_register_on_exit() call to be auto-generated in the first-phase interrupt stub (with __interrupt keyword), that calls  the second-phase function (that you show), that calls your ISR function.  For example:

    Also, rather than calling the __bis_SR_register() on your own to enter LPM4, you can use the Power module that comes with the kernel to do this automatically from the Idle loop.  See: processors.wiki.ti.com/.../BIOS_for_the_MSP430

    Scott