• novoton-启动代码


    启动文件:startup_M451Series.s

     1 ; Reset Handler
     2 
     3 Reset_Handler   PROC
     4                 EXPORT  Reset_Handler             [WEAK]
     5                 IMPORT  SystemInit
     6                 IMPORT  __main
     7                 
     8                 LDR     R0, =0x40000100
     9                 ; Unlock Register                
    10                 LDR     R1, =0x59
    11                 STR     R1, [R0]
    12                 LDR     R1, =0x16
    13                 STR     R1, [R0]
    14                 LDR     R1, =0x88
    15                 STR     R1, [R0]
    16 
    17                 ; Init POR
    18                 LDR     R2, =0x40000024
    19                 LDR     R1, =0x00005AA5
    20                 STR     R1, [R2]
    21 
    22                 ; Select INV Type
    23                 LDR     R2, =0x40000200
    24                 LDR     R1, [R2]
    25                 BIC     R1, R1, #0x1000
    26                 STR     R1, [R2]
    27 
    28                 ; Lock register
    29                 MOVS    R1, #0
    30                 STR     R1, [R0]                
    31                 
    32                 
    33                 LDR     R0, = SystemInit
    34                 BLX     R0
    35                 LDR     R0, = __main
    36                 BX      R0
    37                 ENDP

    从复位中断函数可以知道,系统复位后先 执行 SystemInit 函数,后执行 __main 函数,由 __main 转到用户  main()  函数。

     1 /**
     2  * Initialize the system
     3  *
     4  * @param  None
     5  * @return None
     6  *
     7  * @brief  Setup the microcontroller system.
     8  *         Initialize the System.
     9  */
    10 void SystemInit(void)
    11 {
    12     /* ToDo: add code to initialize the system
    13              do not use global variables because this function is called before
    14              reaching pre-main. RW section maybe overwritten afterwards.          */
    15     
    16     SYS_UnlockReg();
    17     /* One-time POR18 */
    18     if((SYS->PDID >> 12) == 0x945)
    19     {
    20         M32(GCR_BASE+0x14) |= BIT7;
    21     }
    22     /* Force to use INV type with HXT */
    23     CLK->PWRCTL &= ~CLK_PWRCTL_HXTSELTYP_Msk;
    24     SYS_LockReg();
    25 
    26 
    27 #ifdef EBI_INIT
    28     extern void SYS_Init();
    29     extern void EBI_Init();
    30     
    31     SYS_UnlockReg();
    32     SYS_Init();
    33     EBI_Init();
    34     SYS_LockReg();
    35 #endif
    36 
    37     /* FPU settings ------------------------------------------------------------*/
    38 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
    39     SCB->CPACR |= ((3UL << 10 * 2) |               /* set CP10 Full Access */
    40                    (3UL << 11 * 2));               /* set CP11 Full Access */
    41 #endif
    42 
    43 }

    __main 函数 完成C语言加载所需的资源,后执行跳转用户 main 函数。

  • 相关阅读:
    MyBatis+MySQL 返回插入的主键ID
    微信被动回复用户消息-文本消息-springmvc环境下自动生成xml
    微信自动回复消息示例
    微信自定义菜单
    微信获取二维码
    微信被动回复用户消息-文本消息-填坑
    微信获得access-token
    设置ckeditor的高度
    Java三行代码搞定MD5加密
    Highchart
  • 原文地址:https://www.cnblogs.com/llw2017/p/9063641.html
Copyright © 2020-2023  润新知