2012-05-03 07:08 AM
Hello everyone!
Help me, please, to understand where is the problem. I have my own bootloader, located at 0x08000000. And user application I locate at 0x08019000. The algorithm of my bootloader is: 1.After reset I have timeout at about 5 sec.If the connection between MCU and PC throught flash loader demonstrator is set, I load program and reboot MCU by NVIC_SystemReset(). 2. If there is no connection between MCU and PC and5 sec left I load user application. I use for connection between MCU and PC USART2. And in user application I want to use it too, but in another way. It is all right when I load symple programm which does notuse interrupts, it works correctly. But when I load programm that use USART2 and interrupts from USART2 the programm doesn't work. The code is:void JumpToApplication (uint32_t ApplicationAddress)
{
typedef void (*pFunction)(void);
pFunction Jump_To_Application;
uint32_t JumpAddress;
NVIC_SetVectorTable(NVIC_VectTab_FLASH, USER_PROG_OFFSET);
if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000) //Провер�?ем, е�?ть ли что-нибудь по адре�?у (там должно лежать значение SP дл�? приложени�?, его кладет линкер)
{
JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4); //�?дре�? перехода из вектора Reset
Jump_To_Application = (pFunction) JumpAddress; //Указатель на функцию перехода
__set_MSP(*(__IO uint32_t*) ApplicationAddress); //У�?танавливаем SP приложени�?
Jump_To_Application(); //Запу�?каем приложение
}
}
/*====================================================================================================*/
int main (void)
{
InitBootCLK();
InitTimer(TIM2, 100000);//4�?ек
NVICTmrInit(TIM2,TIM2_IRQn,1);
InitUSARTPeriph(USART_SPEED,USART_Pins,BOOT_USART,USART_Interrupt);
TmrOn(TIM2);
TIM_ITConfig(TIM2,TIM_IT_Update,ENABLE);
while (!BootLoaderStack.TIMEOUT_FLAG){} //ждем 4 �?екунды по�?ле запу�?ка
switch (BootLoaderStack.TIMEOUT_FLAG)
{
case TIMER_SRC: {
AppAddr=((ReadFromFlash(PRG_ADDR_CELL)<<
16
)|ReadFromFlash(PRG_ADDR_CELL+2));//+USER_PROG_OFFSET;
if (((AppAddr>=FLASH_START_ADDR)&&(AppAddr<=FLASH_END_ADDR))||((AppAddr>=SRAM_START_ADDR)&&(AppAddr<=SRAM_END_ADDR)))
{
RCC->APB1RSTR=0;
RCC->APB2RSTR=0;
RCC->APB1ENR=0;
RCC->APB2ENR=0;
TmrOff(TIM2);
TIM_ITConfig(TIM2,TIM_IT_Update,DISABLE);
USART_Cmd(USART2,DISABLE);
USART_DeInit(USART2);
USART_ITConfig(USART2,USART_IT_TC,DISABLE);
USART_ITConfig(USART2,USART_IT_RXNE,DISABLE); */
__disable_irq ();
JumpToApplication(AppAddr);
}
else
{
while (1)
{
BootLoaderProcessing();
if (BootLoaderStack.APPLICATION_READY_FLAG)
NVIC_SystemReset();
}
}
break;
case BOOT_SRC:
{
while (1)
{
BootLoaderProcessing();
if (BootLoaderStack.APPLICATION_READY_FLAG)
NVIC_SystemReset();
}
} break;
default: break;
} }
2012-05-03 10:23 AM
Interrupt should still be workable, as long as the vector table is correct, and the core knows where it is. I needs to be on a 512-byte boundary.
To be honest you could delay for 4 seconds, and poll the serial port without using timer or usart interrupts. Break out the debugger and dig in.2012-05-04 10:28 AM
Hi,
You should update the Vector Table base offset. For example, if your application start at 0x08004000, the vector table base offset should be 0x4000. to update VT go to system_stm32fxxx.c file and set VECT_TAB_OFFSET to 0x4000 or call NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x4000) function2012-05-04 12:58 PM
You should update the Vector Table base offset. For example, if your application start at 0x08004000, the vector table base offset should be 0x4000.
to update VT go to system_stm32fxxx.c file and set VECT_TAB_OFFSET to 0x4000 or call NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x4000) function
He does haveNVIC_SetVectorTable(NVIC_VectTab_FLASH, USER_PROG_OFFSET);
I might just use NVIC_SetVectorTable(0x08019000, 0);
2012-12-06 02:09 AM
Hi,
Is the solution of this problem found yet? It seems like that I have the same issue with an STM32F051 microcontroller, Regards, Evert Huijben