Texas Instruments TMS320F20x/F24x DSP Computer Drive User Manual


 
Using the Algorithms With C Code to Erase and Reprogram the ’F240
PRELIMINARY
A-48
PRELIMINARY
extern int erase(); /* Declare external func for flash erase. */
extern int program(); /* Declare external func for flash programming */
extern c240init(); /* Declare external func for C240 register init’l’n */
extern wdtoff(); /* Declare external func for wdt disable */
main()
{
int *a;
asm(” CLRC CNF ”); /* map B0 to data space */
c240init(); /* initialize key ’240 registers */
wdtoff(); /* disable WD timer (works when VCCP=5v) */
if (erase(0xff00,0x0000,0x3fff))
{ /*Flash is erased, now let’s program it.*/
/* Init program buffer. */
a=(int *)0x200; /*Use last 128 words of B1 DARAM for data buffer*/
a[0]=0x7A80;
a[1]=0x0FDF;
a[2]=0x7A80;
/*Program the flash from the buffer*/
if (program(0xff00,0x200,0x0000,0x3))
{ /*Flash programmed ok.*/
while(1){} /*Spin here forever*/
}
else
{ /*Flash fails programming, EXIT*/
while(1){} /*Spin here forever*/
}
}
else
{ /*Flash fails erase, EXIT*/
while(1){} /*Spin here forever*/
}
}
A.6.2 Linker Command File for TMS320F240 Sample C Code
/**********************************************************************/
/* Filename: F240_EXT.CMD */
/* Description: Linker command file for ’F240 example of on–chip flash */
/* programming from C–code. This command file links the */
/* example to addr 0x8000 of the offchip SRAM, so that */
/* the debugger can be used to set breakpoints. */
/* Notes: */
/* 1. The object modules for the standard flash algos */
/* are expected to be in a subdirectory (ALGOS) of */
/* the path of this file. */
/**********************************************************************/
/* Rev1.0 03/98 JGC */
/**********************************************************************/