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.

MSP432P401R: Store information while working with LPM35 MSP432

Part Number: MSP432P401R

Hi, I am currently trying to make this code works. What it does is sending the value of the variable "AAA" every minute after leaving the LPM35  through serial in order to know if its constantly increased value can be stored in the same variable. While looking to the data sent every minute, I can see that it is value is the same as the beginning of the code, somehow entering the sleep mode is resetting the variable value. Does anyone know why? Is there something I could do?  

#include <ti/devices/msp432p4xx/driverlib/driverlib.h>

#include <stdint.h>
#include <stdbool.h>
#include "printf.h"
int i;
uint_fast8_t min = 10;
int AAA = 0;

RTC_C_Calendar calendarTime =
{
    0,      /* Seconds */
    10,     /* Minutes */
    10,     /* Hour */
    2,      /* Day of Week */
    19,     /* Day */
    11,     /* Month */
    2013    /* Year */
};

const eUSCI_UART_Config uartConfig3 =
{
        EUSCI_A_UART_CLOCKSOURCE_SMCLK,          // SMCLK Clock Source
        19,                                      // BRDIV = 78
        8,                                       // UCxBRF = 2
        85,                                       // UCxBRS = 0
        EUSCI_A_UART_NO_PARITY,                  // No Parity
        EUSCI_A_UART_LSB_FIRST,                  // LSB First
        EUSCI_A_UART_ONE_STOP_BIT,               // One stop bit
        EUSCI_A_UART_MODE,                       // UART mode
        EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION  // Oversampling
};

int main(void)
{

    WDT_A_holdTimer();

    if (MAP_ResetCtl_getPCMSource() & RESET_LPM35)
    {
        /* Clearing the PCM Reset flags */
        MAP_ResetCtl_clearPCMFlags();

        /* Unlocking the latched GPIO/LPM configuration flag */
        PCM->CTL1 = PCM_CTL1_KEY_VAL;


        CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_3);

        GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1, GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION);
        UART_initModule(EUSCI_A0_BASE, &uartConfig3);
        UART_enableModule(EUSCI_A0_BASE);
        printf(EUSCI_A0_BASE, "AAA = %i\r\n", AAA);
        AAA++;
    }

    /* Terminating all remaining pins to minimize power consumption. This is
        done by register accesses for simplicity and to minimize branching API
        calls */
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PA, PIN_ALL16);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PB, PIN_ALL16);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PC, PIN_ALL16);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PD, PIN_ALL16);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PE, PIN_ALL16);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PJ, PIN_ALL16);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PA, PIN_ALL16);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PB, PIN_ALL16);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PC, PIN_ALL16);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PD, PIN_ALL16);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PE, PIN_ALL16);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PJ, PIN_ALL16);

    /* Configuring LFXTOUT and LFXTIN for XTAL operation and P1.0 for LED */
    MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_PJ,
            GPIO_PIN0 | GPIO_PIN1, GPIO_PRIMARY_MODULE_FUNCTION);

    /* Setting LFXT to lowest drive strength and current consumption */
    MAP_CS_startLFXT(CS_LFXT_DRIVE0);

    /* Disabling high side voltage monitor/supervisor */
    MAP_PSS_disableHighSide();

    /* Initializing RTC to 11/19/2013 10:10:00 */
    calendarTime.minutes = min;
    MAP_RTC_C_initCalendar(&calendarTime, RTC_C_FORMAT_BINARY);

    /* Setting alarm for one minute later */
    min = min+1;
    MAP_RTC_C_setCalendarAlarm(min,10,2,19);

    /* Setting up interrupts for the RTC. Once we enable interrupts, if there
     * was a pending interrupt due to a wake-up from partial shutdown then the
     * ISR will immediately fire and blinkLED will be set to true.*/
    MAP_RTC_C_enableInterrupt(RTC_C_CLOCK_ALARM_INTERRUPT);
    MAP_Interrupt_enableInterrupt(INT_RTC_C);
    MAP_Interrupt_enableMaster();

    /* Starting the RTC and going into LP3.5 */
    MAP_RTC_C_startClock();
    MAP_PCM_shutdownDevice(PCM_LPM35_VCORE0);
}

/* RTC ISR */
void RTC_C_IRQHandler(void)
{
    MAP_RTC_C_clearInterruptFlag(MAP_RTC_C_getInterruptStatus());
}

  • Hi Josue,

    you do not have a loop implemented to increase AAA you send it once in the if statement but I don't see how it shoudl be repeated.
    Also I do not see how your interrupt from the RTC should go back.

    What your code is doing is going to LPM3.5 that you get a RESET triggered by RTC which will bring you out of LPM3.5.
    However the reset will reset your variables which are located in RAM as well.

    How to handle a wake-up from LPM3.5 and decide if this was a wake-up or a real reset is very good shown in example "msp432p401_x_rtc_lpm35_01" which you can find in the CCS resource explorer.

    If you want to restore your variable you should store them before LPM3.5 entry in flash to ensure you can use after the POR triggered LPM3.5 wake-up.

**Attention** This is a public forum