打印
[STM32F0]

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

[复制链接]
4979|15
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
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 很给力!
5
amanda_s| | 2015-7-14 17:38 | 只看该作者
楼主描述的有点乱。
如果是想将中断向量表放在0x20000000的位置,除了将向量表从flash中拷过来(对比一下memory的内容,就知道是否拷贝过来了),还要修改VTOR寄存器的值,来告诉内核向量表的位置。

使用特权

评论回复
6
wenlong0601|  楼主 | 2015-7-15 14:21 | 只看该作者
SLHSu37 发表于 2015-7-14 17:02
官方例程一个是bootloader,一个是app,都仔细看一下配置

请问大神,您有官方的源文件吗?特别是app部分的。我还是感觉app改写的不对。

使用特权

评论回复
7
wenlong0601|  楼主 | 2015-7-15 14:30 | 只看该作者
SLHSu37 发表于 2015-7-14 17:02
官方例程一个是bootloader,一个是app,都仔细看一下配置

app部分的例子一直没有找见,一直都是只有iap部分的例子啊。

使用特权

评论回复
8
笑苍天| | 2015-7-15 15:16 | 只看该作者
5楼正解。

使用特权

评论回复
9
SLHSu37| | 2015-7-15 16:01 | 只看该作者
官方:STM32F0xx_AN4065_FW_V1.0.0 -> Project -> STM32F0xx_IAP -> MDK-ARM           : bootloder
                                                                                             \ - --> binary_template : app

使用特权

评论回复
10
351327851| | 2015-7-15 16:20 | 只看该作者
顶一个。

使用特权

评论回复
11
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里的配置,对比了好久,也查看了其他参数的设置,问题依旧啊!?我真不知道该怎么办了。:'(

使用特权

评论回复
12
wenlong0601|  楼主 | 2015-7-16 10:05 | 只看该作者
#define APPLICATION_ADDRESS     (uint32_t)0x08003000
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
#if   (defined ( __CC_ARM ))
  __IO uint32_t VectorTable[48] __attribute__((at(0x20000000)));
#elif (defined (__ICCARM__))
#pragma location = 0x20000000
  __no_init __IO uint32_t VectorTable[48];
#elif defined   (  __GNUC__  )
  __IO uint32_t VectorTable[48] __attribute__((section(".RAMVectorTable")));
#elif defined ( __TASKING__ )
  __IO uint32_t VectorTable[48] __at(0x20000000);
#endif
void IAP_Set()
{
        uint32_t i = 0;
        for(i = 0; i < 48; i++)
  {
    VectorTable[i] = *(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));
  }

  /* Enable the SYSCFG peripheral clock*/
  //RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE);
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
  /* Remap SRAM at 0x00000000 */
  SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);
}
void Delay(__IO uint32_t nTime)
{
  TimingDelay = nTime;

  while(TimingDelay != 0);
}
void TimingDelay_Decrement(void)
{
  if (TimingDelay != 0x00)
  {
    TimingDelay--;
  }
}
int main(void)
{
//        LED_Init();
//        USART_Configuration();
//        //ÉèÖÃÖжÏÏòÁ¿±íµÄλÖÃÔÚ 0x3000
//        SystemInit();
  IAP_Set();
        SystemInit();
        LED_Init();
        USART_Configuration();
        if (SysTick_Config(SystemCoreClock / 1000))
  {
    /* Capture error */
    while (1);
  }
       
        while(1)
        {
                LED_Open();//´ò¿ªledµÆ
                Delay(500);
                UART_send_byte(0x31);
                LED_Close();//¹ØµôledµÆ
    Delay(500);               
                UART_send_byte(0x33);
        }
}

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

使用特权

评论回复
13
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中。不知道怎么搞。哎。参考了历程还是没解决。

使用特权

评论回复
14
hwh123| | 2015-7-16 12:34 | 只看该作者
在吗?,加我私下讨论下。我也正在研究这个问题呢

使用特权

评论回复
15
wenlong0601|  楼主 | 2015-7-16 12:39 | 只看该作者
hwh123 发表于 2015-7-16 12:34
在吗?,加我私下讨论下。我也正在研究这个问题呢

在的,我权限不够,不能和你聊天,加我qq:1184015843

使用特权

评论回复
16
wenlong0601|  楼主 | 2015-7-17 11:59 | 只看该作者
谢谢各位了,应该是哪里设置的不对了。结贴。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

29

帖子

2

粉丝