AnsweredAssumed Answered

Bootloader and interrupts in user application

Question asked by slinko.natali on May 3, 2012
Latest reply on Dec 6, 2012 by Evert
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 and 5 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 not use 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;
 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)
    InitTimer(TIM2, 100000);//4сек
    while (!BootLoaderStack.TIMEOUT_FLAG){} //ждем 4 секунды после запуска
    switch  (BootLoaderStack.TIMEOUT_FLAG)
                case    TIMER_SRC:  {
                                        if (((AppAddr>=FLASH_START_ADDR)&&(AppAddr<=FLASH_END_ADDR))||((AppAddr>=SRAM_START_ADDR)&&(AppAddr<=SRAM_END_ADDR))) 
                                            USART_ITConfig(USART2,USART_IT_RXNE,DISABLE);  */
                                            __disable_irq ();
                                                 while (1)
                                                            if (BootLoaderStack.APPLICATION_READY_FLAG)
                case    BOOT_SRC:   
                                     while (1)
                                                            if (BootLoaderStack.APPLICATION_READY_FLAG)
                                    }   break;
                default:                break;
            } }