MSPM0L1306 启动文件详析

[复制链接]
 楼主| xyz549040622 发表于 2023-7-30 21:35 | 显示全部楼层 |阅读模式
  1. #include <stdint.h>
  2. #include <ti/devices/msp/msp.h>

  3. /* Linker variable that marks the top of the stack. */
  4. extern unsigned long __STACK_END;

  5. /* External declaration for the reset handler that is to be called when the */
  6. /* processor is started                                                     */
  7. extern __NO_RETURN void __PROGRAM_START(void);

  8. /* Forward declaration of the default fault handlers. */
  9. void Default_Handler            (void) __attribute__((weak));
  10. extern void Reset_Handler       (void) __attribute__((weak));

  11. /* Processor Exceptions */
  12. extern void NMI_Handler         (void) __attribute__((weak, alias("Default_Handler")));
  13. extern void HardFault_Handler   (void) __attribute__((weak, alias("Default_Handler")));
  14. extern void SVC_Handler         (void) __attribute__((weak, alias("Default_Handler")));
  15. extern void PendSV_Handler      (void) __attribute__((weak, alias("Default_Handler")));
  16. extern void SysTick_Handler     (void) __attribute__((weak, alias("Default_Handler")));

  17. /* Device Specific Interrupt Handlers */
  18. extern void GROUP0_IRQHandler   (void) __attribute__((weak, alias("Default_Handler")));
  19. extern void GROUP1_IRQHandler   (void) __attribute__((weak, alias("Default_Handler")));
  20. extern void TIMG1_IRQHandler    (void) __attribute__((weak, alias("Default_Handler")));
  21. extern void ADC0_IRQHandler     (void) __attribute__((weak, alias("Default_Handler")));
  22. extern void SPI0_IRQHandler     (void) __attribute__((weak, alias("Default_Handler")));
  23. extern void UART1_IRQHandler    (void) __attribute__((weak, alias("Default_Handler")));
  24. extern void UART0_IRQHandler    (void) __attribute__((weak, alias("Default_Handler")));
  25. extern void TIMG0_IRQHandler    (void) __attribute__((weak, alias("Default_Handler")));
  26. extern void TIMG2_IRQHandler    (void) __attribute__((weak, alias("Default_Handler")));
  27. extern void TIMG4_IRQHandler    (void) __attribute__((weak, alias("Default_Handler")));
  28. extern void I2C0_IRQHandler     (void) __attribute__((weak, alias("Default_Handler")));
  29. extern void I2C1_IRQHandler     (void) __attribute__((weak, alias("Default_Handler")));
  30. extern void DMA_IRQHandler      (void) __attribute__((weak, alias("Default_Handler")));


  31. /* Interrupt vector table.  Note that the proper constructs must be placed on this to */
  32. /* ensure that it ends up at physical address 0x0000.0000 or at the start of          */
  33. /* the program if located at a start address other than 0.                            */
  34. #if defined (__ARM_ARCH) && (__ARM_ARCH != 0)
  35. void (* const interruptVectors[])(void)  __attribute((used)) __attribute__((section (".intvecs"))) =
  36. #elif defined (__TI_ARM__)
  37. #pragma RETAIN(interruptVectors)
  38. #pragma DATA_SECTION(interruptVectors, ".intvecs")
  39. void (* const interruptVectors[])(void) =
  40. #else
  41. #error "Compiler not supported"
  42. #endif
  43. {
  44.     (void (*)(void))((uint32_t)&__STACK_END),
  45.                                            /* The initial stack pointer */
  46.     Reset_Handler,                         /* The reset handler         */
  47.     NMI_Handler,                           /* The NMI handler           */
  48.     HardFault_Handler,                     /* The hard fault handler    */
  49.     0,                                     /* Reserved                  */
  50.     0,                                     /* Reserved                  */
  51.     0,                                     /* Reserved                  */
  52.     0,                                     /* Reserved                  */
  53.     0,                                     /* Reserved                  */
  54.     0,                                     /* Reserved                  */
  55.     0,                                     /* Reserved                  */
  56.     SVC_Handler,                           /* SVCall handler            */
  57.     0,                                     /* Reserved                  */
  58.     0,                                     /* Reserved                  */
  59.     PendSV_Handler,                        /* The PendSV handler        */
  60.     SysTick_Handler,                       /* SysTick handler           */
  61.     GROUP0_IRQHandler,                     /* GROUP0 interrupt handler  */
  62.     GROUP1_IRQHandler,                     /* GROUP1 interrupt handler  */
  63.     TIMG1_IRQHandler,                      /* TIMG1 interrupt handler   */
  64.     0,                                     /* Reserved                  */
  65.     ADC0_IRQHandler,                       /* ADC0 interrupt handler    */
  66.     0,                                     /* Reserved                  */
  67.     0,                                     /* Reserved                  */
  68.     0,                                     /* Reserved                  */
  69.     0,                                     /* Reserved                  */
  70.     SPI0_IRQHandler,                       /* SPI0 interrupt handler    */
  71.     0,                                     /* Reserved                  */
  72.     0,                                     /* Reserved                  */
  73.     0,                                     /* Reserved                  */
  74.     UART1_IRQHandler,                      /* UART1 interrupt handler   */
  75.     0,                                     /* Reserved                  */
  76.     UART0_IRQHandler,                      /* UART0 interrupt handler   */
  77.     TIMG0_IRQHandler,                      /* TIMG0 interrupt handler   */
  78.     0,                                     /* Reserved                  */
  79.     TIMG2_IRQHandler,                      /* TIMG2 interrupt handler   */
  80.     0,                                     /* Reserved                  */
  81.     TIMG4_IRQHandler,                      /* TIMG4 interrupt handler   */
  82.     0,                                     /* Reserved                  */
  83.     0,                                     /* Reserved                  */
  84.     0,                                     /* Reserved                  */
  85.     I2C0_IRQHandler,                       /* I2C0 interrupt handler    */
  86.     I2C1_IRQHandler,                       /* I2C1 interrupt handler    */
  87.     0,                                     /* Reserved                  */
  88.     0,                                     /* Reserved                  */
  89.     0,                                     /* Reserved                  */
  90.     0,                                     /* Reserved                  */
  91.     0,                                     /* Reserved                  */
  92.     DMA_IRQHandler,                        /* DMA interrupt handler     */

  93. };

  94. /* Forward declaration of the default fault handlers. */
  95. /* This is the code that gets called when the processor first starts execution */
  96. /* following a reset event.  Only the absolutely necessary set is performed,   */
  97. /* after which the application supplied entry() routine is called.  Any fancy  */
  98. /* actions (such as making decisions based on the reset cause register, and    */
  99. /* resetting the bits in that register) are left solely in the hands of the    */
  100. /* application.                                                                */
  101. void Reset_Handler(void)
  102. {
  103.     /* Jump to the ticlang C Initialization Routine. */
  104.     __asm("    .global _c_int00\n"
  105.           "    b       _c_int00");
  106. }


  107. /* This is the code that gets called when the processor receives an unexpected  */
  108. /* interrupt.  This simply enters an infinite loop, preserving the system state */
  109. /* for examination by a debugger.                                               */
  110. void Default_Handler(void)
  111. {
  112.     /* Enter an infinite loop. */
  113.     while(1)
  114.     {
  115.     }
  116. }


 楼主| xyz549040622 发表于 2023-7-30 21:51 | 显示全部楼层
从(void (*)(void))((uint32_t)&__STACK_END)开始的代码,对应的是中断向量表,这个中断向量表总长度为48个,详见下图: 微信截图_20230730215045.png

微信截图_20230730215059.png

您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:qq群: 嵌入式系统arm初学者 224636155←← +→→点击-->小 i 精品课全集,21ic公开课~~←←→→点击-->小 i 精品课全集,给你全方位的技能策划~~←←

2841

主题

19330

帖子

110

粉丝
快速回复 在线客服 返回列表 返回顶部
个人签名:qq群: 嵌入式系统arm初学者 224636155←← +→→点击-->小 i 精品课全集,21ic公开课~~←←→→点击-->小 i 精品课全集,给你全方位的技能策划~~←←

2841

主题

19330

帖子

110

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