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:从中断返回后、如果没有手动退出、代码将无法移动到 IF 块中("step-overt")

Guru**** 2988540 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1024320/msp432p401r-code-wouldn-t-move-into-if-block-without-a-manual-step-over-after-returning-from-an-interrupt

器件型号:MSP432P401R

您好!

我正在处理一个简单的项目、在该项目中、我获取 UART 输入、传输它、然后设置标志、然后根据主无限 while 环路中的标志值切换 LED。 问题是、当我的标志被置位时、程序卡在 IF 条件上、在调试模式下、我必须点击步越才能进入 IF 块。 它也不会在运行模式下切换 LED。 我的 if 条件为 true、标志为易失性、并且在反汇编中也找不到任何奇怪的东西。 非常感谢您对此提供的任何帮助。  

我将 CCS v10与编译器 TI 20.2.0 LTS 搭配使用。

这是基于基本 UART "UART_PC_ECHO_12MHz_brclk"示例的代码。

#include <stdio.h>
#include "driverlib.h"
#include "gpio.h"

/* Standard Includes */

#include <stdbool.h>

volatile bool flag = 0;

/* UART Configuration Parameter. These are the configuration parameters to
 * make the eUSCI A UART module to operate with a 9600 baud rate. These
 * values were calculated using the online calculator that TI provides
 * at:
 *software-dl.ti.com/.../index.html
 */
const eUSCI_UART_Config uartConfig =
{
        EUSCI_A_UART_CLOCKSOURCE_SMCLK,          // SMCLK Clock Source
        78,                                     // BRDIV = 78
        2,                                       // UCxBRF = 2
        0,                                       // 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)
{
    /* Halting WDT  */
    //MAP_WDT_A_holdTimer();

    GPIO_setAsOutputPin(
        GPIO_PORT_P2,
        GPIO_PIN0
        );


    /* Selecting P1.2 and P1.3 in UART mode */
    MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,
            GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION);

    /* Setting DCO to 12MHz */
    CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_12);

    /* Configuring UART Module */
    MAP_UART_initModule(EUSCI_A0_BASE, &uartConfig);

    /* Enable UART module */
    MAP_UART_enableModule(EUSCI_A0_BASE);

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

    while(1)
    {
        if(flag == 1){

            flag = 0;
            GPIO_toggleOutputOnPin(
                        GPIO_PORT_P2,
                        GPIO_PIN0
                        );
        }
        //MAP_PCM_gotoLPM0();

    }
}

/* EUSCI A0 UART ISR - Echoes data back to PC host */
void EUSCIA0_IRQHandler(void)
{
    uint32_t status = MAP_UART_getEnabledInterruptStatus(EUSCI_A0_BASE);

    MAP_UART_clearInterruptFlag(EUSCI_A0_BASE, status);

    if(status & EUSCI_A_UART_RECEIVE_INTERRUPT_FLAG)
    {
        MAP_UART_transmitData(EUSCI_A0_BASE, MAP_UART_receiveData(EUSCI_A0_BASE));
        flag = 1;

    }

}

谢谢!

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    在"CCS Debug Properties for Program/Memory Load Options" 中、"Disable Interrupt "选项 设置为什么、更改这些选项会改变行为?

    我尚未尝试运行您的代码。