TMS320F2812启动过程


TMS320F2812从内部Flash启动的详细流程说明:

1>程序硬件复位或者软件复位;

2>判断XMP/MC信号状态;若该信号为高电平时是微处理器模式,此时外部接口Zone7有效,Zone7被映射到存储空间的高位,这样向量表指向外部,系统从Zone7启动。若该信号为低电平时是微计算机模式,此时Zone7被禁止,向量表指向Boot ROM,这样系统既可以从内部存储空间启动,也可以从外部存储空间启动。

3>到Boot ROM的0x3FFC00处取出复位向量,跳到Boot函数;(TMS320F2812有一块Flash地址从0x3FF000-0x3FFFFF在出厂时TI已经固化好了引导程序InitBoot,InitBoot函数判断几个GPIO引脚来判断使用哪一种引导模式,比如Flash Boot模式,检测SPICLKA(GPIOF2),SPISTEA(GPIOF3),SCITXDA(GPIOF4),MDXA(GPIOF12)的电平,当都为高电平时表明是片内Flash Boot模式,那么InitBoot执行完后跳转到0x3F7FF6处,这个时候指令占据两个字节,刚好在代码模块之前。一定是跳转指令才行)

4>采集I/O管脚状态;

5>根据I/O状态选择Boot方式;

6>如果是Flash,程序退出Boot函数,跳转到0x3F7FF6(codestart);

7>取出跳转指令,跳转到自己的指定地址或者C初始化的入口_C_INT00(0x3F6000)处(DSP281x_CodeStartBranch.asm中);

8>在C初始化的入口_C_INT00对一些变量,堆栈和寄存器进行必要的设置,该函数在C的库函数内(RTS Library);

9>进入main函数(0x3F658E,这个地址不是固定的,但是在Flash里面)。

 

从上电到我们的主函数运行之间这段时间里TMS320F2812到底做了些什么?TMS320F2812是怎样引导程序运行的?下面叙述其启动过程:

  在TMS320F2812中有一个引脚XMP/MC,当该引脚的为高电平时表示是微处理器模式(Microprocessor),当该引脚为低电平时表示微机算计模式(Microcomputer)。当为微处理器模式时,TMS320F2812内部的Boot ROM被禁止,通过Zone7(0x3FC000)从外部调引导程序启动,TMS320F2812复位以后,其复位向量是固定的0x3FFFC0,如果为微处理器模式,那么复位后的复位向量指向的外部的地址,即0x3FFFC0是Zone7处的地址;若为微机算计模式,那么0x3FFFC0指向的是TMS320F2812的片内Flash的址。下面就以微机算计模式加以说明其过程。

  上电复位后,复位向量是指向片内Flash的0x3FFFC0,TMS320F2812有一块Flash地址从0x3FF000-0x3FFFFF在出厂时已经固化好了引导程序。在0x3FFFC0处是一条跳转指令,跳到InitBoot(地址0x3FFC00)函数处执行InitBoot代码,该InitBoot代码就是TI在DSP出厂时固化在Flash中的。InitBoot Assembly Routine将选择SelectBootMode Function启动模式函数。这个函数由GPIO 引脚的状态决定启动类型。

                                                                                     引导模式选择

SCITXDA

(GPIOF4)

MDXA

(GPIOF12)

SPISTEA

(GPIOF3)

SPICLK

(GPIOF2)

Mode Selected
1  x  x  x

跳转到地址为0x3F7FF6的Flash,用户必须在这里编写分支语句优先于复位,以按需要重新定位代码的执行

0 1  x x

调用SPI_Boot 以从外部的EEPROM载入

0 1 1

调用SCI_Boot 以从SCI-A载入

0 1 0

J跳转到 H0 SARAM 0x3F8000

0 0 0 1

跳转到OTP地址0x3D7800

0 0 0 0

调用Parallel_Boot从GPIO 端口B载入 

 

 

  一旦启动结束,选择启动模式函数返回一入口地址给InitBoot函数。入口地址是退出BootLoader之后代码开始执行的起始点。InitBoot接着将会调用ExitBoot子程序,把CPU寄存器的状态恢复到复位状态。比如Flash Boot模式,那么InitBoot执行完后跳转到0x3F7FF6处(codestart处),此位置刚好在128位(CSM)密码位置之前,你要在0x3F7FF6处放置跳转指令,以跳转到你要去的地方,比如是BootLoader或应用代码,通常的跳转去处是_c_int00。在0x3F 7FF6 处放置跳转指令的方法如下(DSP281x_CodeStartBranch.asm中):

 1 ***********************************************************************  2 *File:DSP281x_CodeStartBranch.asm  3 *Apply to:F2810,F2811,F2812 devices.  4 *Author: David Chan, WintechDigital System Inc.  5 ***********************************************************************  6 
 7 WD_DISABLE    .set    1        ;set to 1 to disable WD, else set to 0
 8 
 9  .ref _c_int00 10 
11 *********************************************************************** 12 * Function: codestart section 13 * 14 * Description: Branch to code starting point 15 *********************************************************************** 16 
17     .sect "codestart"
18 
19 code_start:
20     .if WD_DISABLE == 1
21         LB wd_disable       ;Branch to watchdog disable code
22  .else 23         LB _c_int00         ;Branch to start of boot.asm in RTS library
24  .endif 25 
26 ;end codestart section
27 
28 
29 *********************************************************************** 30 * Function: wd_disable 31 * 32 * Description: Disables the watchdog timer 33 *********************************************************************** 34     .if WD_DISABLE == 1
35 
36  .text 37 wd_disable:
38     SETC OBJMODE        ;Set OBJMODE for 28x object code
39     EALLOW              ;Enable EALLOW protected register access
40     MOVZ DP, #7029h>>6  ;Set data page for WDCR register
41     MOV @7029h, #0068h  ;Set WDDIS bit in WDCR to disable WD
42     EDIS                ;Disable EALLOW protected register access
43     LB _c_int00         ;Branch to start of boot.asm in RTS library
44 
45  .endif 46 
47 ;end wd_disable
48 
49 
50  .end 51     
52 ; end of file CodeStartBranch.asm
 1 MEMORY  2 {  3     PAGE 0 :  4  RAMM0 : origin = 0x000000, length = 0x000400  5  /******************************************************************  6         *On F281x L0 SARAM is 0x008000-0x008FFF, and L1 SARAM is  7  * 0x009000-0x009FFF.  8  * Hence, whole SECURE_RAM is 0x008000-0x009FFF  9  *******************************************************************/  10  SECURE_RAM : origin = 0x008000, length = 0x002000  11         BEGIN_FLASH    : origin = 0x3F7FF6, length = 0x000002    /*RAM run:0x3F9FFa*/  12         
 13  RESET : origin = 0x3FFFC0, length = 0x000002  14  VECTORTS : origin = 0x3FFFc2, length = 0x00003e  15      
 16  FLASH : origin = 0x3d8000, length = 0x01FF80 /* for Flash */  17         
 18  /*PRAMH0 : origin = 0x3F8000, length = 0x001ff4 */ /*for RAM 0x001ffe*/  19     
 20              
 21     PAGE 1 :  22  /* SARAM */  23  RAMM1 : origin = 0x000400, length = 0x000400  24  DRAMH0 : origin = 0x3f8000, length = 0x002000  25         
 26 }  27  
 28  
 29 SECTIONS  30 {  31    /* Allocate program areas: */  32    secureRamfuncs    : LOAD=FLASH, PAGE = 0 /*PRAMH0*/  33                          RUN=SECURE_RAM,PAGE=0
 34  RUN_START(_secureRamFuncs_runstart),  35  LOAD_START(_secureRamFuncs_loadstart),  36  LOAD_END(_secureRamFuncs_loadend)  37    .reset           : > FLASH,      PAGE = 0 /*PRAMH0*/  38    .text            : > FLASH,      PAGE = 0 /*PRAMH0*/  39    .cinit           : > FLASH,      PAGE = 0 /*PRAMH0*/  40    /* zhaowritefunc  : LOAD=FLASH,PAGE=0
 41                     RUN=SECURE_RAM,PAGE=0
 42  RUN_START(_zhaowritefunc_runstart),  43  LOAD_START(_zhaowritefunc_loadstart),  44  LOAD_END(_zhaowritefunc_loadend)  45     zhaoreadfunc  : LOAD=FLASH,PAGE=0
 46                     RUN=SECURE_RAM,PAGE=0
 47  RUN_START(_zhaoreadfunc_runstart),  48  LOAD_START(_zhaoreadfunc_loadstart),  49  LOAD_END(_zhaoreadfunc_loadend)  50     transmit_work_scifunc  : LOAD=FLASH,PAGE=0
 51                     RUN=SECURE_RAM,PAGE=0
 52  RUN_START(_transmit_work_scifunc_runstart),  53  LOAD_START(_transmit_work_scifunc_loadstart),  54  LOAD_END(_transmit_work_scifunc_loadend)  55     transmit_work_usbfunc  : LOAD=FLASH,PAGE=0
 56                     RUN=SECURE_RAM,PAGE=0
 57  RUN_START(_transmit_work_usbfunc_runstart),  58  LOAD_START(_transmit_work_usbfunc_loadstart),  59  LOAD_END(_transmit_work_usbfunc_loadend)*/  60 
 61  /*  frame_valid_low_test_programfuncs:  LOAD=FLASH,PAGE=0
 62                     RUN=SECURE_RAM,PAGE=0
 63  RUN_START(_frame_valid_low_test_programfuncs_runstart),  64  LOAD_START(_frame_valid_low_test_programfuncs_loadstart),  65  LOAD_END(_frame_valid_low_test_programfuncs_loadend)  66 
 67 frame_valid_high_test_programfuncs:  LOAD=FLASH,PAGE=0
 68                     RUN=SECURE_RAM,PAGE=0
 69  RUN_START(_frame_valid_high_test_programfuncs_runstart),  70  LOAD_START(_frame_valid_high_test_programfuncs_loadstart),  71  LOAD_END(_frame_valid_high_test_programfuncs_loadend)  72 */  73 /* fifo_empty_test_programfuncs  : LOAD=FLASH,PAGE=0
 74                     RUN=SECURE_RAM,PAGE=0
 75  RUN_START(_fifo_empty_test_programfuncs_runstart),  76  LOAD_START(_fifo_empty_test_programfuncs_loadstart),  77  LOAD_END(_fifo_empty_test_programfuncs_loadend)  78  fifo_half_test_programfuncs  : LOAD=FLASH,PAGE=0
 79                     RUN=SECURE_RAM,PAGE=0
 80  RUN_START(_fifo_half_test_programfuncs_runstart),  81  LOAD_START(_fifo_half_test_programfuncs_loadstart),  82  LOAD_END(_fifo_half_test_programfuncs_loadend)  83 */  84 
 85 
 86 /*    tint0_sub_lowRAMFUNCS  : LOAD=FLASH,PAGE=0
 87                     RUN=SECURE_RAM,PAGE=0
 88  RUN_START(_tint0_sub_lowRAMFUNCS_runstart),  89  LOAD_START(_tint0_sub_lowRAMFUNCS_loadstart),  90  LOAD_END(_tint0_sub_lowRAMFUNCS_loadend) */  91  /* Jump to the Flash boot mode Entry! */  92     codestart        : LOAD = BEGIN_FLASH, PAGE = 0
 93     
 94     /* Allocate data areas: */  95    .stack           : > RAMM1,       PAGE = 1
 96    .bss             : > DRAMH0,      PAGE = 1
 97    .ebss            : > DRAMH0,      PAGE = 1
 98    .const           : > DRAMH0,      PAGE = 1
 99    .econst          : > DRAMH0,      PAGE = 1      
100    .sysmem          : > DRAMH0,      PAGE = 1
101  }

  上面代码执行后跳到C初始化的入口_c_int00(0x3F6000) ,在C初始化的入口,_c_int00对一些变量,堆栈和寄存器进行必要的设置,这个函数在运行支持库(rts.lib)中,_c_int00函数为建立C运行环境,需完成以下工作:

  1. 为系统堆栈产生.stack块,并初始化堆栈指针;
  2. .cinit块将初始化数据拷贝到.bss块中相应的变量;
  3. 对寄存器进行必要的配置,调用main函数开始运行C程序。

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM