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.

LPM3 set and wake

Part Number: MSP430FR2476

Tool/software: Code Composer Studio

Hi everyone,
Our application is in SPI client structure and works properly in LPM0 mode. But we want to run LPM3 for power consumption.

In our application, there is an interrupt structure in which we open our SPI module before SPI transfer via a pin and turn off the SPI module after SPI transfer.
So I set the input and output to LPM3 here. When the SPI module is opening (at the beginning of the SPI transfer) I exit LPM3, while closing the SPI module (end of the SPI transfer) I log in to LPM3.
But I could not get a response at a spi speed of 1MHz. I would like to state that I also take the departure time from LPM3 into account. What do you think could be the problem? I will be grateful if you could help me.

Here is the code piece:

// Port 2 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=PORT2_VECTOR
__interrupt void Port_2(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(PORT1_VECTOR))) Port_2 (void)
#else
#error Compiler not supported!
#endif
{

    if((P2IFG&CSSpiT)==CSSpiT)
    {
        if((P2IES&CSSpiT)==CSSpiT)                        // If Hi/Lo Edge Interrupt Detected (SPI TRANSFER ENDS)
        {
            __bis_SR_register_on_exit(LPM3_bits);
            UCB0CTLW0 |= UCSWRST;                        // **Initialize USCI state machine**
            RESET_BUSY;
            TA0CCTL0 |= CCIE;                             // TACCR0 interrupt enabled
        }
        else                                              // If Lo/Hi Edge Interrupt Detected (SPI TRANSFER ENDS)
        {
            __bic_SR_register_on_exit(LPM3_bits);
            SET_BUSY;
            TA0CCTL0 &= ~CCIE;                             // TACCR0 interrupt enabled
            UCB0CTLW0 &= ~UCSWRST;                        // **Initialize USCI state machine**
            UCB0IE |= UCRXIE;                         // Enable USCI_B0 RX interrupt
        }

        P2IES ^= CSSpiT;                                 //Toggle Edge Selection
        P2IFG &= ~CSSpiT;                                // P1.2 IFG cleared

    }
    else
    {
        P2IFG = 0;                                       // If undesired interrupt Erase All  P2IFG
    }

}

  • Hi Ege,

    The comments in the else section do not match the code. 

                TA0CCTL0 &= ~CCIE;                             // TACCR0 interrupt enabled
                UCB0CTLW0 &= ~UCSWRST;                        // **Initialize USCI state machine**

    The above code would disable the TACCR0 interrupt & reset the eUSCI_B state machine. Was that the intent?

    Section 23.3.7 Using the SPI Mode With Low-Power Modes of the User's guide (www.ti.com/.../slau445) suggests the wakeup time of the CPU must also be considered. Have you accounted for this? Also look at the Note in that section.

    Srinivas

  • What is your symptom exactly? Does your slave not wake up at all, or are the bits "smeared"?

        __bis_SR_register_on_exit(LPM3_bits);

    Putting main() into LPM ("remotely", as it were) is rather hazardous. Either (a) main was in the middle of doing something, in which case it immediately stalls or (b) main was already in LPM, in which case this is redundant. I'm not sure how that relates to your symptom, but it's something to consider.

    >            TA0CCTL0 |= CCIE;

    What clock (TASSEL) are you using for TA0? SMCLK doesn't run in LPM3. [Ref Data Sheet (SLASEO5C) Table 6-1].

  • Hi Srinivas,

    Sorry for the wrong comments on the code. There are no problems on this piece of code. It was the intent (disable the TACCR0 interrupt & reset the eUSCI_B state machine).

    In application, using a pin we start spi machine before transfer and stop after spi transfer to avoid current leak. Application works fine with LPM0 mode but for power consumption issues, we want to use LPM3 mode when there were no spi transfer. Before sending package from host, I set gpio to high and wait until spi module started. After receive on the host side, I wait and stop the spi state machine using given code piece. I would like to exit from LPM3 mode before sending SPI package and turn pack to LPM3 mode when spi transfer finished. How can I achieve this ? What is the proper way to toggle between enter and exit LPM3 ?

    One more thing, SMCLOCK is used for spi module and DCO is used as a clock source. I guess DCO disabled on LPM3, should I initialze DCO after wake from LPM3 ?

    Thanks in advance
    Ege

  • Hi Bruce,
    TA0 uses ACLK, but spi module uses SMCLK and DCO is used as clock source. I guess DCO is off in LPM3 mode. Should I initialize DCO after wake from LPM3 ? Also, What is the proper way to toggle between enter and exit LPM3 ?

    Thanks in advance
    Ege

  • I thought this was the SPI slave, in which case the SPI uses SCK (from the master), not SMCLK. Or maybe I misunderstood your description?

    main(), i.e. non-ISR, should decide when to go into LPM. If it really has nothing to do, there's nothing wrong with main ending in a "while(1) LPM3;", but an ISR shouldn't impose LPM on main.

    The DCO switches off when all of its "users" stop, which would be the case in LPM3. It (re)starts automatically on an interrupt.

    For completeness, I'll mention that the DCO restarts using its previous settings -- if it were stopped for a long time and/or the environment changed drastically (outdoors on a Winter day), it might take some time (100ms maybe) for the FLL to correct the DCO, which isn't the span of a usual ISR. This usually isn't a big concern.

    ----------------

    I'm still not sure I understand your symptom.

**Attention** This is a public forum