This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF51 simple vector deflection function?

I use STM32F4+nRF51822 through the SPI interface. I want to achieve nRF51822 DFU with SPI operation, now upgrade the simple LED to work properly. But can not work when using Gazlle. I know it is because the interrupt vector table is not offset, but I find a lot of there is no simple and feasible way to achieve interrupt vector offset similar to the STM32F0 routines like this example; Or you can give me a simple bootloader and APP procedures for a simple upgrade demo without SD.

  if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFF0000 ) == 0x20000000)//判断用户程序的起始地址是否为0X8002000保证内容为RAM起始64KB之内。
    { 
      JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);           //应用程序的复位地址
      Jump_To_Application = (pFunction) JumpAddress;
      __set_MSP(*(__IO uint32_t*) ApplicationAddress);                          
      
      FLASH_Lock();
      memcpy((void*)0x20000000, (void*)ApplicationAddress, 0x100);      //拷贝应用程序的中断向量表到ROM的起始地址
      SYSCFG->CFGR1 |= 0x03;                                            //设置中断向量表为ROM的起始地址
      Jump_To_Application();                                              //调用reset的中断处理函数
    }

thanks.

  • hi , The last time that the example does not work, do you have a simple way to achieve? My entire circuit framework is as follows.

    image description

    2、I use the SPI interface, but has been unable to enter the SPI interrupt. My application starts with 0x0000C000. Bootloader_active = 1 at the beginning of the program; can you help me to see why?

    __asm void BranchIntHandler(void) {
                MRS    R0, PSR ;
                /* Mask the interrupt number only */
                MOVS   R1, #0x3F  ; 
                ANDS   R0, R1     ; /*R0 keeps the interrupt number*/
                extern bootloader_active;
                LDR R1 , =bootloader_active;
                LDR R2, [R1];
                CMP R2,#1;
                BEQ bootload;
                LDR     R2, =0x0000C000;
                /* Irq address position = IRQ No * 4 */
                LSLS   R0, R0, #2 ;
                /* Fetch the user vector offset */
                LDR    R0, [R0, R2];
                /* Jump to user interrupt vector */
                BX     R0  ;
                
    bootload 
                CMP R0, #0x24;
                BEQ swi0
                CMP R0, #0x21;
                BEQ rtc1
                CMP R0, #0x16;
                BEQ gpiote
                CMP R0, #0x12;
                BEQ uart0
    						CMP R0, #0x14;
                BEQ spi1
                //RETURN code needed
    swi0            
                EXTERN SWI0_IRQHandler_Bootloader[WEAK]
                LDR    R0,=SWI0_IRQHandler_Bootloader
                B execute ;    
                
    rtc1            
                EXTERN  RTC1_IRQHandler_Bootloader[WEAK] 
                LDR    R0,=RTC1_IRQHandler_Bootloader
                B execute ;
    						
    spi1            
                EXTERN  SPI1_TWI1_IRQHandler_Bootloader[WEAK] 
                LDR    R0,=SPI1_TWI1_IRQHandler_Bootloader
                B execute ;
                
    uart0
                EXTERN  UART0_IRQHandler_Bootloader[WEAK]     
                LDR    R0,=UART0_IRQHandler_Bootloader
                B execute ;            
    gpiote            
                EXTERN  GPIOTE_IRQHandler_Bootloader[WEAK]     
                LDR    R0,=GPIOTE_IRQHandler_Bootloader
                                     
    execute            
                BX     R0  ;
                
    }
    
  • Hi Xiao,

    You meant you couldn't enter SPI interrupt when in the bootloader or when in the application ? You set Bootloader_active = 1 when you are in bootloader and set it to 0 when you exit the bootloader before you jump to your application.

    You can simply add a break point inside BranchIntHandler() and check what happens there when you receive a SPI interrupt.

Related