[STM32F0] stm32f051单片机从iap跳转app中断响应异常

[复制链接]
 楼主| wenlong0601 发表于 2015-7-14 16:05 | 显示全部楼层 |阅读模式
按照官方f0的iap通过串口ymodem模式发送app的bin文件。app的设置如上图。
 楼主| wenlong0601 发表于 2015-7-14 16:07 | 显示全部楼层

串口输入中断也是没有反应的。如果把IAP_Set();去掉,正常运行,闪灯、串口中断输入、输出都是正常的。IAP_Set();这个函数也参考了其他网站的资料。
view sourceprint?
01
#define APPLICATION_ADDRESS     ((uint32_t)0x08003000)
02
/* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/
03
#if   (defined ( __CC_ARM ))
04
  __IO uint32_t VectorTable[48] __attribute__((at(0x20000000)));
05
#elif (defined (__ICCARM__))
06
#pragma location = 0x20000000
07
  __no_init __IO uint32_t VectorTable[48];
08
#elif defined   (  __GNUC__  )
09
  __IO uint32_t VectorTable[48] __attribute__((section(".RAMVectorTable")));
10
#elif defined ( __TASKING__ )
11
  __IO uint32_t VectorTable[48] __at(0x20000000);
12
#endif
13
void IAP_Set()
14
{
15
   uint32_t i = 0;
16

17

18
  /* Copy the vector table from the Flash (mapped at the base of the application
19
     load address 0x08003000) to the base address of the SRAM at 0x20000000. */      
20
  for(i = 0; i < 48; i++)
21
  {
22
    *((uint32_t*)(0x20000000 + (i << 2)))=*(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));
23
    }
24
  /* Enable the SYSCFG peripheral clock*/
25
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
26
    //RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE);
27
    /* Remap SRAM at 0x00000000 */
28
  SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);
29
     
30
}  
31
int main(void)
32
{
33
    LED_Init();
34
    USART_Configuration();
35
    //ÉèÖÃÖжÏÏòÁ¿±íµÄλÖÃÔÚ 0x3000
36
  IAP_Set();
37
    LED_Init();
38
    USART_Configuration();
39
    while(1)
40
    {
41
        LED_Open();//´ò¿ªledµÆ
42
        delay();
43
        UART_send_byte(0x31);
44
        LED_Close();//¹ØµôledµÆ
45
    delay();      
46
        UART_send_byte(0x33);
47
    }
48
}


有的说官网的RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE);应该换成 RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);就能解决进不了中断的问题。
试了试,没啥效果。
 楼主| wenlong0601 发表于 2015-7-14 16:24 | 显示全部楼层
我的问题可能描述的很不清楚,在这儿发帖发图,编辑代码不是很熟练。好心人可以看看这里,原帖三W点openedv.com/posts/list/53496.htm[//url/]
SLHSu37 发表于 2015-7-14 17:02 | 显示全部楼层
官方例程一个是bootloader,一个是app,都仔细看一下配置

评分

参与人数 1威望 +1 收起 理由
wenlong0601 + 1 很给力!

查看全部评分

amanda_s 发表于 2015-7-14 17:38 | 显示全部楼层
楼主描述的有点乱。
如果是想将中断向量表放在0x20000000的位置,除了将向量表从flash中拷过来(对比一下memory的内容,就知道是否拷贝过来了),还要修改VTOR寄存器的值,来告诉内核向量表的位置。
 楼主| wenlong0601 发表于 2015-7-15 14:21 | 显示全部楼层
SLHSu37 发表于 2015-7-14 17:02
官方例程一个是bootloader,一个是app,都仔细看一下配置

请问大神,您有官方的源文件吗?特别是app部分的。我还是感觉app改写的不对。
 楼主| wenlong0601 发表于 2015-7-15 14:30 | 显示全部楼层
SLHSu37 发表于 2015-7-14 17:02
官方例程一个是bootloader,一个是app,都仔细看一下配置

app部分的例子一直没有找见,一直都是只有iap部分的例子啊。
笑苍天 发表于 2015-7-15 15:16 | 显示全部楼层
5楼正解。
SLHSu37 发表于 2015-7-15 16:01 | 显示全部楼层
官方:STM32F0xx_AN4065_FW_V1.0.0 -> Project -> STM32F0xx_IAP -> MDK-ARM           : bootloder
                                                                                             \ - --> binary_template : app
351327851 发表于 2015-7-15 16:20 | 显示全部楼层
顶一个。
 楼主| wenlong0601 发表于 2015-7-16 09:58 | 显示全部楼层
SLHSu37 发表于 2015-7-15 16:01
官方:STM32F0xx_AN4065_FW_V1.0.0 -> Project -> STM32F0xx_IAP -> MDK-ARM           : bootloder
       ...

大哥,参照bootloader里的配置,对比了好久,也查看了其他参数的设置,问题依旧啊!?我真不知道该怎么办了。:'(
 楼主| wenlong0601 发表于 2015-7-16 10:05 | 显示全部楼层
  1. #define APPLICATION_ADDRESS     (uint32_t)0x08003000
  2. /* Private macro -------------------------------------------------------------*/
  3. /* Private variables ---------------------------------------------------------*/
  4. #if   (defined ( __CC_ARM ))
  5.   __IO uint32_t VectorTable[48] __attribute__((at(0x20000000)));
  6. #elif (defined (__ICCARM__))
  7. #pragma location = 0x20000000
  8.   __no_init __IO uint32_t VectorTable[48];
  9. #elif defined   (  __GNUC__  )
  10.   __IO uint32_t VectorTable[48] __attribute__((section(".RAMVectorTable")));
  11. #elif defined ( __TASKING__ )
  12.   __IO uint32_t VectorTable[48] __at(0x20000000);
  13. #endif
  14. void IAP_Set()
  15. {
  16.         uint32_t i = 0;
  17.         for(i = 0; i < 48; i++)
  18.   {
  19.     VectorTable[i] = *(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));
  20.   }

  21.   /* Enable the SYSCFG peripheral clock*/
  22.   //RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE);
  23.         RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
  24.   /* Remap SRAM at 0x00000000 */
  25.   SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);
  26. }
  27. void Delay(__IO uint32_t nTime)
  28. {
  29.   TimingDelay = nTime;

  30.   while(TimingDelay != 0);
  31. }
  32. void TimingDelay_Decrement(void)
  33. {
  34.   if (TimingDelay != 0x00)
  35.   {
  36.     TimingDelay--;
  37.   }
  38. }
  39. int main(void)
  40. {
  41. //        LED_Init();
  42. //        USART_Configuration();
  43. //        //ÉèÖÃÖжÏÏòÁ¿±íµÄλÖÃÔÚ 0x3000
  44. //        SystemInit();
  45.   IAP_Set();
  46.         SystemInit();
  47.         LED_Init();
  48.         USART_Configuration();
  49.         if (SysTick_Config(SystemCoreClock / 1000))
  50.   {
  51.     /* Capture error */
  52.     while (1);
  53.   }
  54.        
  55.         while(1)
  56.         {
  57.                 LED_Open();//´ò¿ªledµÆ
  58.                 Delay(500);
  59.                 UART_send_byte(0x31);
  60.                 LED_Close();//¹ØµôledµÆ
  61.     Delay(500);               
  62.                 UART_send_byte(0x33);
  63.         }
  64. }

设置也是按照官网配的,不过用的变压器是keil5.14
生产bin文件配置E:\Keil_v5\ARM\ARMCC\bin\fromelf.exe --bin --output ./gg.bin ./led.axf

 楼主| wenlong0601 发表于 2015-7-16 10:11 | 显示全部楼层
amanda_s 发表于 2015-7-14 17:38
楼主描述的有点乱。
如果是想将中断向量表放在0x20000000的位置,除了将向量表从flash中拷过来(对比一下me ...

To build such application, some special configuration has to be performed:
1. Set the application load address at 0x08003000, using your toolchain linker file
2. To be able to serve the application interrupts, you need to relocate the vector
   table (which contains the interrupt handlers). However, unlike CortexM3 and CortexM4,
   the CortexM0 processor do not support vector table relocation (it is fixed at
   address 0x00000000).
   A solution will be to relocate by software the vector table to the internal SRAM:  
    - Copy the vector table from the Flash (mapped at the base of the application load
      address 0x08003000) to the base address of the SRAM at 0x20000000.
    - Remap SRAM at address 0x00000000, using SYSCFG_MemoryRemapConfig() function
    - Then once an interrupt occurs, the CortexM0 processor will fetch the interrupt
      handler start address from the relocated vector table in SRAM, then it will
      jump to execute the interrupt handler located in the Flash.
   This operation should be done at the initialization phase of the application.
M0和M3,M4不一样啊,中断向量表固定在0x00000位置。重定向后的中断地址存在RAM中。不知道怎么搞。哎。参考了历程还是没解决。
hwh123 发表于 2015-7-16 12:34 | 显示全部楼层
在吗?,加我私下讨论下。我也正在研究这个问题呢
 楼主| wenlong0601 发表于 2015-7-16 12:39 | 显示全部楼层
hwh123 发表于 2015-7-16 12:34
在吗?,加我私下讨论下。我也正在研究这个问题呢

在的,我权限不够,不能和你聊天,加我qq:1184015843
 楼主| wenlong0601 发表于 2015-7-17 11:59 | 显示全部楼层
谢谢各位了,应该是哪里设置的不对了。结贴。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

29

帖子

2

粉丝
快速回复 在线客服 返回列表 返回顶部

2

主题

29

帖子

2

粉丝
快速回复 在线客服 返回列表 返回顶部