Problem with relocating code to 0x0800 0400
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-07-29 1:28 PM
Posted on July 29, 2012 at 22:28
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 #vector-table #code-relocation #s
Labels:
- Labels:
-
Interrupt
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-07-29 2:47 PM
Posted on July 29, 2012 at 23:47
I'd double check the listing and map files. Step through the code and confirm the vector table is where you want it, and contains vectors to where you expect. ie dump out at 0x08000400
Check also that VTOR points to your vector table, prior to enabling SysTick. Check to see if SystemInit() is being called before main() to set up the speed and vector table.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-07-30 4:41 PM
Posted on July 31, 2012 at 01:41
Thank you for the tips Clive1.
The issue was that in misc.h file, the following macro was changed #define NVIC_VectTab_FLASH ((uint32_t)0x08002400) So the vector table pointed to the Applications's Vector table.