MSP432如果主循环不休眠

请问TI工程师:

       我发现一个问题,如果程序如下写

void main(void)
{

   初始化设置中断


   while(1)
{
   主循环程序    

}    

}

好像主循环程序不能运行

必须是如下框架才行

void main(void)
{

   初始化设置中断


    //进入休眠
    while (1)
    {
        MAP_PCM_gotoLPM0();

        中断唤醒后的程序


    }

}

设计的程序在各类中断中,然后通过中断唤醒在while(1)中执行。

我想问的是 MSP432能进行全速运行模式吗?  即主循环也有前台程序总是运行方式。

  • 您现在是想MSP432一直在Active模式?那您可以看一下下面的代码

    /* --COPYRIGHT--,BSD
     * Copyright (c) 2017, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     * --/COPYRIGHT--*/
    /*******************************************************************************
     * MSP432 PCM - Active mode ~1mA current consumption with LDO & DCO.
     *
     * Description: In this very simple example, the device is configured to operate
     * at 4MHz with the LDO on. The example shows 1mA current consumption
     * while using the DCO for MCLK in active mode.
     *
     *                MSP432P4111
     *             ------------------
     *         /|\|                  |
     *          | |                  |
     *          --|RST               |
     *            |                  |
     *            |                  |
     *            |                  |
     *            |                  |
     *
     ******************************************************************************/
    /* DriverLib Includes */
    #include <ti/devices/msp432p4xx/driverlib/driverlib.h>
    
    /* Standard Includes */
    #include <stdint.h>
    #include <stdbool.h>
    
    volatile uint32_t mclk = 0;
    volatile uint32_t curPowerState;
    
    int main(void)
    {
        /* Halting the Watch-dog */
        MAP_WDT_A_holdTimer();
    
        /* 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);
    
        /* Before we set the DCO, transition the device to use LDO */
        MAP_PCM_setPowerState(PCM_AM_LDO_VCORE0);
    
        /* At 4MHz in VCORE0, MSP432P401R needs 0 wait states */
        MAP_FlashCtl_setWaitState(FLASH_BANK0, 0);
        MAP_FlashCtl_setWaitState(FLASH_BANK1, 0);
    
        /* Enabling FPU for DCO Frequency calculation */
        MAP_FPU_enableModule();
    
        /* Set DCO to 4MHz */
        MAP_CS_setDCOFrequency(4000000);
    
        /* Set MCLK = DCO = 4MHz */
        MAP_CS_initClockSignal(CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1);
    
        /* Disabling high side voltage monitor/supervisor */
        MAP_PSS_disableHighSide();
    
        while (1)
        {
            mclk = MAP_CS_getDCOFrequency();
            curPowerState = MAP_PCM_getPowerState();
            while(1);
        }
    }
    

    If a post answers your question, please mark it with the "verify answer" button.

    若是回复解决了您的问题,请点击“是”确认答案。谢谢!

  • 回复 user3738963:

    很高兴能帮到您

    If a post answers your question, please mark it with the "verify answer" button.

    若是回复解决了您的问题,请点击“是”确认答案。谢谢!