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: Vector Push back function not working properly

Part Number: MSP430FR5994


Hi, I have been trying to use the vector push back in CCS v12, with MSP430, it doesnt work properly, I get values like -12284 in the vector array after pushing back an enum. This is the sample function that utlizes it.

/**< 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);
}

I wish to note that this same function implemented the same way, works properly with a C2000 mcu

  • Hi Peace,

    According to your code, it seems do determine whether the new event has the same old event, if not, add the event, and if so, exit the function.

    I suggest you enter the debug mode and go steps to let MCU run code one by one, and then check the value of the variable to find which part cause the issue.

    B.R.

    Sal

  • Unsolicited: It looks as though you're reading ([indexing]) one-too-many from the vector. I think this gives undefined results (not an error). 

    This may or may not affect what you're seeing.

  • Hi Peace,

    If you have any updates, you can reply to the post directly.

    If the problem has been solved and please clicked "This resolved my issue" button on this thread.

    B.R.

    Sal

**Attention** This is a public forum