AnsweredAssumed Answered

Problem with relocating code to 0x0800 0400

Question asked by curiousa on Jul 29, 2012
Latest reply on Jul 31, 2012 by curiousa

Hello everyone, thanks for reading the post.
For STM32 : I am running into an issue when I try to run my code from 0x08000400 instead of 0x08000000. I am using IAR tools. As soon as I execute the statement the system hangs.
             if (SysTick_Config(SystemCoreClock / 100))

When I change my project setting to run from 0x08000000 everything works fine and my interrupt handler for the SysTick_Handler(void) runs fine (following code).
void SysTick_Handler(void)
{
  timerHandler();
}

It looks like issue with the vector table but I have no idea what I am missing that the STM32 does not like.
Here is my code for the board_init function:

************************************************************************************
void Board_Init( void )
{
     __IO ErrorStatus HSEStartUpStatus = SUCCESS;

 /* 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 */
            RCC_PCLK2Config(RCC_HCLK_Div1);
   
            /* 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 via the RCC_APB2ENR register */
    /* Changed 22 July 11 MSB.                               */
     RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA
                 |  RCC_APB2Periph_GPIOB
    |  RCC_APB2Periph_GPIOC
                 |  RCC_APB2Periph_TIM1
      |  RCC_APB2Periph_USART1 , ENABLE);
 /*------------------- Resources Initialization -----------------------------*/
        //Set the Vector table to start at address 0x0400
        NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0400);        
        /* Configure the systick */
 SysTick_Configuration();

 /* GPIO Configuration */
 GPIO_Config();
        /* Configure USART */
 USART_Config();
 /* Interrupt Configuration */
 NVIC_Config();
}
************************************************************************************

Any ideas, suggestions ?

Thanks

 

Outcomes