yu_jsh:
是变量未初始化造成的.const类型,CONST_COPY.set1.注意看TI的帮助文档.DSP是代码、数据分离的,上电时候必须把常数copy到RAM区域.***************************************************************************** boot v7.01* Copyright(c)1988-1996TexasInstrumentsInc.********************************************************************************************************************************************************** Thismodulecontainsthefollowingdefinitions:** __stack -Stackmemoryarea* _c_int0 -Bootfunction* _var_init -Functionwhichprocessesinitializationtables*****************************************************************************.global _c_int0,cinit.global _main,_abort.global.bss,end*****************************************************************************FORC50,DEFINEADDRESSESOFMEMORYMAPPEDREGISTERS****************************************************************************.if.tms32050.mmregs.endif*****************************************************************************CONSTCOPYOPTION*Ifyoursystemcannotsupportallocatinganinitializedsectiontodata*memory,andyouwantthebootroutinetocopy.constfromprogramto*datamemory,thensetthisCONST_COPYvariableto1**Notethecodethatdoesthecopydependsonyouhavingthefollowing*inyourlinkercommandfile**MEMORY*{* PAGE0:PROG:.../*'PROG'AND'DATA'AREEXAMPLENAMES*/* PAGE1:DATA:...* ...* }**SECTIONS*{* ...* .const:load=PROGPAGE0,run=DATAPAGE1* {* __const_run=.;* *(.c_mark)* *(.const)* __const_length=.-__const_run;* }* ...*}****************************************************************************CONST_COPY.set1*****************************************************************************FORCONSTCOPY,DEFINETHELOADADDRESSOFTHE.constSECTION*DEPENDSONLINKERCOMMANDFILEBEINGWRITTENASABOVE****************************************************************************.ifCONST_COPY.sect".c_mark".label__const_load.global__const_run,__const_length.text.endif;CONST_COPY*****************************************************************************C50ONLY. ZEROTHEWAITSTATES. IFYOURSYSTEMUSESAC5xANDSUPPORTS*ZEROWAITSTATES,CHANGETHISFLAGTO1****************************************************************************ZERO_WAIT_STATES.set0*****************************************************************************DECLARETHESTACK. SIZEISDETERMINEDBYTHELINKEROPTION-stack****************************************************************************__stack:.usect".stack",0*****************************************************************************FUNCTIONDEF:_c_int0** 1)Setupstack* 2)Setupproperstatus* 3)If"cinit"isnot-1,initglobalvariables* 4)callusers'program*****************************************************************************_c_int0:***************************************************************************** SETUPINITIALSTACKANDFRAMEPOINTERS****************************************************************************LRLK AR0,__stack;setupframepointerLRLK AR1,__stack;setupstackpointer*****************************************************************************INITIALIZESTATUSBITFIELDS*NOT*INITIALIZEDATRESET ****************************************************************************ROVM;turnoffoverflowmode*****************************************************************************INITIALIZESTATUSBITFIELDSWHICHARESETTOTHESESAMEVALUESBYRESET.*IFYOURUNTHISROUTINEFROMRESET,YOUCANCOMMENTOUTTHISCODE.****************************************************************************SPM 0;productshiftcountofzero.if.tms32050LDPK0;accessmemorymappedregsAPL#0fff9h,PMST;setNDX=0andTRM=0.endifSSXM;setSXM=1forLALKcinit*****************************************************************************ONTHEC50,OPTIONALLYZEROTHEWAITSTATEREGISTER****************************************************************************.ifZERO_WAIT_STATES&.tms32050LDPK0SPLK#0,PDWSR.endif***************************************************************************** IFcinitISNOT-1,PROCESSINITIALIZATIONTABLES****************************************************************************LALK cinit;getpointertoinittablesADDK 1BZ skip;if(cinit==-1)CALL _var_init,AR1;var_init()***************************************************************************** CALLUSER'SPROGRAM****************************************************************************skip:.ifCONST_COPYCALLconst_copy.endifCALL _main,AR1CALL _abort,AR1;toneverreturn....page*****************************************************************************FUNCTIONDEF:_var_init** PROCESSINITIALIZATIONTABLES. TABLESAREIN* PROGRAMMEMORYINTHEFOLLOWINGFORMAT:** .word * .word * .word * .word ...** Theinittableisterminatedwithazerolength*****************************************************************************_var_init:*****************************************************************************C2x/C2xxVERSION****************************************************************************.if.tms32025|.tms3202xx ADRK 2;allocatetwowordsoflocalmemory LALK cinit;loadaccumulatorwithbaseoftableLARP AR0***************************************************************************** READINITRECORDHEADER* ANINITRECORDWITHAZEROLENGTHTERMINATESLIST****************************************************************************loop:TBLR *+;readlengthADDK 1TBLR *;readaddressLAR AR2,*-;loadvariableaddressintoar2LAR AR3,*,AR3;loadcountintoar3BANZ copy,*-,AR2;checkforendoftable***************************************************************************** ATENDOFLIST,RETURNTOCALLER**************************************************************************** LARP AR1SBRK 2;deallocatelocalsRET;returnto_c_int0***************************************************************************** PERFORMTHECOPYOFDATAFROMPROGRAMTODATA****************************************************************************copy:ADDK 1;incrementpointertodata TBLR *+,AR3;copydatafromprogramtovariableBANZ copy,*-,AR2;untilcountiszeroADDK 1;pointtobeginningofnextrecordB loop,AR0;goprocessnextrecord.endif;.tms32025|.tms3202xx*****************************************************************************C5xVERSION****************************************************************************.if.tms32050 LALK cinit;loadaccumulatorwithbaseoftableLDPK0;setpageto0forAR2==>BRCR***************************************************************************** READINITRECORDHEADER* ANINITRECORDWITHAZEROLENGTHTERMINATESLIST****************************************************************************loop:TBLR*;readlengthADDK1LARAR2,*,AR2;intoAR2BANZcontinue,*-,AR1;continueifnotzero,decrement***************************************************************************** ATENDOFLIST,RETURNTOCALLER****************************************************************************RETcontinue:LMMRBRCR,AR2;BRCR=AR2=length-1TBLR*ADDK1LARAR2,*,AR2;AR2 =address***************************************************************************** PERFORMTHECOPYOFDATAFROMPROGRAMTODATA****************************************************************************RPTBcopy-1TBLR*+ADDK1NOPcopy:B loop,AR1;goprocessnextrecord.endif;.tms32050.page*****************************************************************************CONSTCOPYROUTINE-COPIESTHE.constSECTIONFROMPROGRAMTODATAMEMORY****************************************************************************.ifCONST_COPYconst_copy:*****************************************************************************C2x/C2xxVERSION-CAN'TUSERPT. COUNTERISONLY8-BITSWIDE****************************************************************************.if.tms32025|.tms3202xxLARPAR3LRLKAR3,#__const_length;AR3=lengthofsectionBANZcont,*-,AR2;CheckforzeroanddecrementBquit;if(zero)quitcont:LRLKAR2,#__const_run;AR2=constaddressindataLALK#__const_load;ACC=constaddressinprogramcloop:TBLR*+,AR3;copyfromprogramtodataADDK1;incrementprogramaddressBANZcloop,*-,AR2;checkforzeroanddecrementquit:LARPAR1;restoreARPtoSPRET;return.endif;.tms32025|.tms3202xx*****************************************************************************C5xVERSION-USESRPTK****************************************************************************.if.tms32050LALK#__const_length;loadlengthofconstsectionBZquit;if0,quitLRLKAR2,#__const_run;AR2=constaddressindataLARPAR2RPT#__const_length-1;repeatlengthtimesBLKP#__const_load,*+;blockcopyfromprogramLARPAR1;restoreARPtoSPquit:RET;return.endif;.tms32050.endif;CONST_COPY.end