This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARM: Using STL vectors

Hi,

I'm writing a C++ program that will run on an STM3210E-EVAL board and I'm having some problems using STL vectors. I'm wondering what I'm doing wrong. (Or if STL vectors are even supported.)

Here's a snippet:

#include <vector>

.
.
.

void func()
{
  std::vector<int> temp;

  temp.push_back(5);
}

When I try to run the debugger on my target, I end up somewhere in assembly land and never reach the beginning of my main() function. (I am not familiar with assembly so, I'm not quite sure where I am or how I got there.)

When I run in simulator mode, everything works fine. (I end up at the beginning of my main() function like I expect.)

It appears that whenever I make any command that increases the size of my vector, I get the same result. If I never insert into my vector or resize it, then the debugger brings me to the beginning of main(), like I'd expect.

The last time I saw something like this was when my heap was 0 and I tried newing something on the heap. If anyone has any ideas, I'd be grateful.

I'm required to write my program in C++ and though I'm not required to use vectors, I really would like to. (I also have a few ideas of how to implement it differently if it turns out that vectors don't work.)

Thanks,

Parents
  • Alright, I added the clock configuration:

    void RCC_Configuration(void)
    {
      /* RCC system reset(for debug purpose) */
      RCC_DeInit();
    
      /* Enable HSE */
      RCC_HSEConfig(RCC_HSE_ON);
    
      /* Wait till HSE is ready */
      HSEStartUpStatus = RCC_WaitForHSEStartUp();
    
      if (HSEStartUpStatus == SUCCESS)
      {
        /* Enable Prefetch Buffer */
        FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
    
        /* Flash 2 wait state */
        FLASH_SetLatency(FLASH_Latency_2);
    
        /* HCLK = SYSCLK */
        RCC_HCLKConfig(RCC_SYSCLK_Div1);
    
        /* PCLK2 = HCLK/2 */
        RCC_PCLK2Config(RCC_HCLK_Div2);
    
        /* PCLK1 = HCLK/2 */
        RCC_PCLK1Config(RCC_HCLK_Div2);
    
        /* PLLCLK = 8MHz * 9 = 72 MHz */
        RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
    
        /* Enable PLL */
        RCC_PLLCmd(ENABLE);
    
        /* Wait till PLL is ready */
        while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
        {}
    
        /* Select PLL as system clock source */
        RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
    
        /* Wait till PLL is used as system clock source */
        while (RCC_GetSYSCLKSource() != 0x08)
        {}
      }
    
      /* Enable peripheral clocks ------------------------------------------*/
      /* GPIOA, GPIOB and SPI1 clock enable */
      RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
    }
    
    

    And I still have the same problem.

Reply
  • Alright, I added the clock configuration:

    void RCC_Configuration(void)
    {
      /* RCC system reset(for debug purpose) */
      RCC_DeInit();
    
      /* Enable HSE */
      RCC_HSEConfig(RCC_HSE_ON);
    
      /* Wait till HSE is ready */
      HSEStartUpStatus = RCC_WaitForHSEStartUp();
    
      if (HSEStartUpStatus == SUCCESS)
      {
        /* Enable Prefetch Buffer */
        FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
    
        /* Flash 2 wait state */
        FLASH_SetLatency(FLASH_Latency_2);
    
        /* HCLK = SYSCLK */
        RCC_HCLKConfig(RCC_SYSCLK_Div1);
    
        /* PCLK2 = HCLK/2 */
        RCC_PCLK2Config(RCC_HCLK_Div2);
    
        /* PCLK1 = HCLK/2 */
        RCC_PCLK1Config(RCC_HCLK_Div2);
    
        /* PLLCLK = 8MHz * 9 = 72 MHz */
        RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
    
        /* Enable PLL */
        RCC_PLLCmd(ENABLE);
    
        /* Wait till PLL is ready */
        while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
        {}
    
        /* Select PLL as system clock source */
        RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
    
        /* Wait till PLL is used as system clock source */
        while (RCC_GetSYSCLKSource() != 0x08)
        {}
      }
    
      /* Enable peripheral clocks ------------------------------------------*/
      /* GPIOA, GPIOB and SPI1 clock enable */
      RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
    }
    
    

    And I still have the same problem.

Children