Chinaunix首页 | 论坛 | 博客
  • 博客访问: 542697
  • 博文数量: 104
  • 博客积分: 4131
  • 博客等级: 上校
  • 技术积分: 1137
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-31 15:05
文章分类

全部博文(104)

文章存档

2011年(13)

2010年(23)

2009年(68)

我的朋友

分类: 嵌入式

2010-09-10 09:08:37

Flash的烧写是实现仿真器的脱离工作,使得DSP上电自动运行的过程,下面我介绍一下对于工程文件的配置,下载步骤很简单,我用的是3.3版本,选择工具F28xx On-Ship Flash Programmer 配置相关信息就可以实现下载;
下面主要介绍对于文件的修改:
首先得准备两个文件:DSP281x_CodeStartBranch.asm和f2812_nonBIOS_flash.cmd
文件内容如下:
DSP281x_CodeStartBranch.asm
***********************************************************************
WD_DISABLE .set 1  ;set to 1 to disable WD, else set to 0
    .ref _c_int00
***********************************************************************
* Function: codestart section
*
* Description: Branch to code starting point
***********************************************************************
    .sect "codestart"
code_start:
    .if WD_DISABLE == 1
        LB wd_disable       ;Branch to watchdog disable code
    .else
        LB _c_int00         ;Branch to start of boot.asm in RTS library
    .endif
;end codestart section

***********************************************************************
* Function: wd_disable
*
* Description: Disables the watchdog timer
***********************************************************************
    .if WD_DISABLE == 1
    .text
wd_disable:
    SETC OBJMODE        ;Set OBJMODE for 28x object code
    EALLOW              ;Enable EALLOW protected register access
    MOVZ DP, #7029h>>6  ;Set data page for WDCR register
    MOV @7029h, #0068h  ;Set WDDIS bit in WDCR to disable WD
    EDIS                ;Disable EALLOW protected register access
    LB _c_int00         ;Branch to start of boot.asm in RTS library
    .endif
;end wd_disable
 
 .end
 
; end of file CodeStartBranch.asm
 
f2812_nonBIOS_flash.cmd
/**********************************************************************
* File: f2812.cmd -- Linker command file for Boot to Flash bootmode.
* History: 09/08/03 - original (based on DSP28 header files v1.00, D. Alter)
**********************************************************************/
MEMORY
{
PAGE 0:    /* Program Memory */
   //ZONE0       : origin = 0x002000, length = 0x002000     /* XINTF zone 0 */
   //ZONE1       : origin = 0x004000, length = 0x002000     /* XINTF zone 1 */
   RAML0       : origin = 0x008000, length = 0x001000     /* on-chip RAM block L0 */
 
   OTP         : origin = 0x3D7800, length = 0x000800     /* on-chip OTP */
   FLASH_IJ    : origin = 0x3D8000, length = 0x004000     /* on-chip FLASH */
   FLASH_GH    : origin = 0x3DC000, length = 0x008000     /* on-chip FLASH */
   FLASH_EF    : origin = 0x3E4000, length = 0x008000     /* on-chip FLASH */
   FLASH_CD    : origin = 0x3EC000, length = 0x008000     /* on-chip FLASH */
   FLASH_AB    : origin = 0x3F4000, length = 0x003F80     /* on-chip FLASH */
   CSM_RSVD    : origin = 0x3F7F80, length = 0x000076     /* Part of FLASHA.  Reserved when CSM is in use. */
   BEGIN_FLASH : origin = 0x3F7FF6, length = 0x000002     /* Part of FLASHA.  Used for "boot to flash" bootloader mode. */
   PASSWORDS   : origin = 0x3F7FF8, length = 0x000008     /* Part of FLASHA.  CSM password locations. */
   BEGIN_H0    : origin = 0x3F8000, length = 0x000002     /* Part of H0.  Used for "boot to H0" bootloader mode. */
 
/*   ZONE7       : origin = 0x3FC000, length = 0x003FC0     /* XINTF zone 7 available if MP/MCn=1 */
   ROM         : origin = 0x3FF000, length = 0x000FC0     /* boot ROM available if MP/MCn=0 */
   RESET       : origin = 0x3FFFC0, length = 0x000002     /* part of boot ROM (MP/MCn=0) or XINTF zone 7 (MP/MCn=1) */
   VECTORS     : origin = 0x3FFFC2, length = 0x00003E     /* part of boot ROM (MP/MCn=0) or XINTF zone 7 (MP/MCn=1) */
PAGE 1 :   /* Data Memory */
   RAMM0       : origin = 0x000000, length = 0x0000400     /* on-chip RAM block M0 */
/*  RAMM01      : origin = 0x000040, length = 0x0003C0*/
   RAMM1       : origin = 0x000400, length = 0x000400     /* on-chip RAM block M1 */
   DEV_EMU     : origin = 0x000880, length = 0x000180     /* Device emulation registers */
   FLASH_REGS  : origin = 0x000A80, length = 0x000060     /* FLASH registers */
   CSM         : origin = 0x000AE0, length = 0x000010     /* Code security module registers */
   XINTF       : origin = 0x000B20, length = 0x000020     /* External interface registers */
   CPU_TIMER0  : origin = 0x000C00, length = 0x000008     /* CPU Timer0 registers (CPU Timer1 and Timer2 are reserved for BIOS)*/
   PIE_CTRL    : origin = 0x000CE0, length = 0x000020     /* PIE control registers */
   PIE_VECT    : origin = 0x000D00, length = 0x000100     /* PIE vector table */
   ECAN_A      : origin = 0x006000, length = 0x000100     /* eCAN registers */
   ECAN_AMBOX  : origin = 0x006100, length = 0x000100     /* eCAN mailboxes */
   SYSTEM      : origin = 0x007010, length = 0x000020     /* System control registers */
   SPI_A       : origin = 0x007040, length = 0x000010     /* SPI registers */
   SCI_A       : origin = 0x007050, length = 0x000010     /* SCI-A registers */
   XINTRUPT    : origin = 0x007070, length = 0x000010     /* External interrupt registers */
   GPIOMUX     : origin = 0x0070C0, length = 0x000020     /* GPIO mux registers */
   GPIODAT     : origin = 0x0070E0, length = 0x000020     /* GPIO data registers */
   ADC         : origin = 0x007100, length = 0x000020     /* ADC registers */
   EV_A        : origin = 0x007400, length = 0x000040     /* Event Manager A registers */
   EV_B        : origin = 0x007500, length = 0x000040     /* Event Manager B registers */
   SCI_B       : origin = 0x007750, length = 0x000010     /* SCI-B registers */
   MCBSP_A     : origin = 0x007800, length = 0x000040     /* McBSP registers */  
   RAML1       : origin = 0x009000, length = 0x001000     /* on-chip RAM block L1 */
   CSM_PWL     : origin = 0x3F7FF8, length = 0x000008     /* CSM password locations in FLASHA */
   //ZONE2       : origin = 0x080000, length = 0x080000
   RAMH0       : origin = 0x3F8002, length = 0x001FFE     /* H0 SARAM */
   ZONE6       : origin = 0x100000, length = 0x080000     /* XINTF zone 6 */
  
}

SECTIONS
{
/*** Compiler Required Sections ***/
  /* Program memory (PAGE 0) sections */
   .text             : > FLASH_AB,         PAGE = 0
   .cinit            : > FLASH_CD,         PAGE = 0
   .pinit            : > FLASH_CD,         PAGE = 0
   .reset            : > RESET,            PAGE = 0, TYPE = DSECT  /* We are not using the .reset section */
  /* Data Memory (PAGE 1) sections */
   .cio              : > RAML1,            PAGE = 1
   .bss              : > RAML1,            PAGE = 1                /* Should be empty with large memory model */
  
   .ebss             : > RAMH0,            PAGE = 1
   .const            : > FLASH_CD,         PAGE = 0                /* Should be empty with large memory model */
   .econst           : > FLASH_CD,         PAGE = 0     
   .stack            : > RAMM1,            PAGE = 1
   .sysmem           : > RAMH0,            PAGE = 1                /* Should be empty with large memory model */
   .esysmem          : > RAMH0,            PAGE = 1
   .switch           : > FLASH_CD,         PAGE = 0
/*** User Defined Sections ***/
   codestart         : > BEGIN_FLASH,      PAGE = 0                /* Used by file CodeStartBranch.asm */
   csm_rsvd          : LOAD = CSM_RSVD,         PAGE = 0                /* Used by file passwords.asm */
   passwords         : LOAD = PASSWORDS,        PAGE = 0                /* Used by file passwords.asm */
   pie_vect          : > PIE_VECT,         PAGE = 1
   secureRamFuncs    :  LOAD = FLASH_AB,  PAGE = 0                /* Used by InitFlash() in SysCtrl.c */
                        RUN = RAML0, PAGE = 0
                        RUN_START(_secureRamFuncs_runstart),
                        LOAD_START(_secureRamFuncs_loadstart),
                        LOAD_END(_secureRamFuncs_loadend)
  /*ramfuncs    :   LOAD = FLASH_AB,  PAGE = 0*/                /* Used by InitFlash() in SysCtrl.c */
                        /*RUN = RAML0, PAGE = 0
                        RUN_START(_ramfuncs_runstart),
                        LOAD_START(_ramfuncs_loadstart),
                        LOAD_END(_ramfuncs_loadend)*/
                        
    ramdata            : >        RAMM0,        PAGE = 1        
  /* .lcddata            : >        ZONE2,        PAGE = 1
   .disdata               : > RAMH0,     PAGE = 1
   .disdata0               : > RAMH0,     PAGE = 1
   .Sint               : > RAMH0,     PAGE = 1
   .Cost               : > RAMH0,     PAGE = 1  */
  
/**********************************************/
/* Allocate Peripheral Frame 0 Register Structures:   */
   DevEmuRegsFile      : > DEV_EMU     PAGE = 1
   FlashRegsFile       : > FLASH_REGS  PAGE = 1
   CsmRegsFile         : > CSM         PAGE = 1
   XintfRegsFile       : > XINTF       PAGE = 1
   CpuTimer0RegsFile   : > CPU_TIMER0  PAGE = 1     
   PieCtrlRegsFile     : > PIE_CTRL    PAGE = 1     
   PieVectTable        : > PIE_VECT    PAGE = 1
   /* Allocate Peripheral Frame 2 Register Structures:   */
   ECanaRegsFile       : > ECAN_A      PAGE = 1  
   ECanaMboxesFile     : > ECAN_AMBOX  PAGE = 1
   /* Allocate Peripheral Frame 1 Register Structures:   */
   SysCtrlRegsFile     : > SYSTEM      PAGE = 1
   SpiaRegsFile        : > SPI_A       PAGE = 1
   SciaRegsFile        : > SCI_A       PAGE = 1
   XIntruptRegsFile    : > XINTRUPT    PAGE = 1
   GpioMuxRegsFile     : > GPIOMUX     PAGE = 1
   GpioDataRegsFile    : > GPIODAT     PAGE = 1
   AdcRegsFile         : > ADC         PAGE = 1
   EvaRegsFile         : > EV_A        PAGE = 1
   EvbRegsFile         : > EV_B        PAGE = 1
   ScibRegsFile        : > SCI_B       PAGE = 1
   McbspaRegsFile      : > MCBSP_A     PAGE = 1
   /* CSM Password Locations */
   CsmPwlFile          : > CSM_PWL     PAGE = 1
  
}
DSP281x_CodeStartBranch.asm这个文件不用修改,f2812_nonBIOS_flash.cmd这个文件看你自己的实际情况了,贴出来的这个在我的2812上是直接可用的,要是下载后程序运行不起来,那得仔细看下这个文件了
 
在文件中的修改如下:
 
#pragma CODE_SECTION (InitFlash, "secureRamFuncs");
void InitFlash(void)
{
        asm(" EALLOW");                                                                        // Enable EALLOW protected register access
        FlashRegs.FPWR.bit.PWR = 3;                                                // Pump and bank set to active mode
        FlashRegs.FSTATUS.bit.V3STAT = 1;                                // Clear the 3VSTAT bit
        FlashRegs.FSTDBYWAIT.bit.STDBYWAIT = 0x01FF;        // Sleep to standby transition cycles
        FlashRegs.FACTIVEWAIT.bit.ACTIVEWAIT = 0x01FF;        // Standby to active transition cycles
        FlashRegs.FBANKWAIT.bit.RANDWAIT = 5;                        // Random access waitstates
        FlashRegs.FBANKWAIT.bit.PAGEWAIT = 5;                        // Paged access waitstates
        FlashRegs.FOTPWAIT.bit.OPTWAIT = 5;                                // Random access waitstates
        FlashRegs.FOPT.bit.ENPIPE = 1;                                        // Enable the flash pipeline
        asm(" EDIS");                                                                        // Disable EALLOW protected register access
/*** Force a complete pipeline flush to ensure that the write to the last register
     configured occurs before returning.  Safest thing is to wait 8 full cycles. ***/
    asm(" RPT #7 || NOP");
}
把这段代码放到DSP28_SysCtrl.c文件中,开始的地方就可以;
然后在你的主程序文件中添加如下:
extern Uint16 secureRamFuncs_runstart;
extern Uint16 secureRamFuncs_loadstart;
extern Uint16 secureRamFuncs_loadend;
在main.c中的InitSysCtrl()之后添加:
 memcpy(&secureRamFuncs_runstart,
  &secureRamFuncs_loadstart,
  &secureRamFuncs_loadend - &secureRamFuncs_loadstart);
  
 /*FLASH 初始化 */  
 InitFlash();
往下你就可以写你自己的程序了;
在测试过程中,你可以找个GPIO口输出0,1看看板子是否跑起来了;
注意:下载完后,断开仿真器,板子断电,拔掉仿真器,板子重新上电,查看GPIO口;
 
 

 
阅读(5836) | 评论(0) | 转发(0) |
0

上一篇:2812 flash编程小结

下一篇:2812 看门狗程序

给主人留下些什么吧!~~