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.

[参考译文] MSP430FR5994:矢量推回功能不能正常工作

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1331473/msp430fr5994-vector-push-back-function-not-working-properly

器件型号:MSP430FR5994

您好、我一直在尝试在 CCS v12中使用向量推回、借助 MSP430、它不能正常工作、我在推回枚举后在向量阵列中获得诸如-12284的值。 这是使用它的示例函数。

/**< project based include files */
#include "app_ui.h"


/**< private variable definition for file */
std::vector<uti_ui::enum_ui_events> ui::event_queue;



/**
 * @brief  Add event to the UI event queue when there is an event
 * @param  enum_ui_events new_event - new event
 * @retval None
 * @details Called from an interrupt due to a new ui event
 */
void ui::UpdateEventQueue(uti_ui::enum_ui_events new_event)
{
    uint16_t queue_size = 0;
    queue_size = ui::event_queue.size();
    if (queue_size >= 1)
    {
        for(uint16_t cou = 0; cou <= queue_size; cou++)
        {
            if (new_event == ui::event_queue[cou]) return;
        }
    }
    ui::event_queue.push_back(new_event);
}

我想指出的是、同样的功能以相同的方式实现、能够与 C2000 MCU 一起正常工作

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

    您好、Peace、

    根据您的代码、似乎可以确定新事件是否具有相同的旧事件、如果没有、则添加事件、如果是、则退出函数。

    我建议 您进入调试模式、逐步让 MCU 逐一运行代码、然后检查变量值以找到导致问题的原因。

    B.R.

    萨尔

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

    未经请求:看起来您正在从向量读取([索引])太多。 我认为这会给出不确定的结果(不是错误)。  

    这可能会也可能不会影响您看到的内容。

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

    您好、Peace、

    如果有任何更新、您可以直接回复此帖子。

    如果问题已解决、请在此主题中单击"此问题已解决我的问题"按钮。

    B.R.

    萨尔