A. Why it is necessary?
Basically, flashing the program into the DSP is a very important step in digital signal processor. In term of Power Supply Converter, the digital controller has been more popular due to the ease of controller modification without changing the hardware. It also offer a smaller circuitry compare to the analog controller. As the consequence the size of the controller can be reduce. These advantages only some part of the digital control advantages.
When a designer has finished writing the program which will be applied to a circuit, testing the performance is the next step. Without flashing the program to our DSP memory, we need to attach our DSP kit to our computer by using a USB or a JTAG emulator. But when we have done a program, we can’t longer attach a computer to run a Power Supply Control, so that we need to transfer all the program to the DSP memory without losing it when the power supply is turned off. So the controller will always work whenever it is run. This is why flashing the program to a DSP memory is necessary.
B. How to flash the program?
In order to flash the program into the memory we need to do some steps. Here, I consider we already done a program.
- Initialize the RAMFlash function and Flash Function by add this code in the initialization step of the main program.
- Add this line after initialization.
void MemCopy(Uint16 *SourceAddr, Uint16* SourceEndAddr, Uint16* DestAddr);
- Main function add this line
- Write the function of InitRAMFLash(void) as shown below
MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
#pragma CODE_SECTION(InitFlash, “ramfuncs“);
- Make sure you already have the InitFlash function, sometimes it already include in DSP2803x_SysCtrl.c, in case it doesn’t include, we can add this line presented below
//Enable Flash Pipeline mode to improve performance
//of code executed from Flash.
FlashRegs.FOPT.bit.ENPIPE = 1;
//Minimum waitstates required for the flash operating
//at a given CPU rate must be characterized by TI.
//Refer to the datasheet for the latest information.
//Set the Paged Waitstate for the Flash
FlashRegs.FBANKWAIT.bit.PAGEWAIT = 2;
//Set the Random Waitstate for the Flash
FlashRegs.FBANKWAIT.bit.RANDWAIT = 2;
//Set the Waitstate for the OTP
FlashRegs.FOTPWAIT.bit.OTPWAIT = 3;
//ONLY THE DEFAULT VALUE FOR THESE 2 REGISTERS SHOULD BE USED
FlashRegs.FSTDBYWAIT.bit.STDBYWAIT = 0x01FF;
FlashRegs.FACTIVEWAIT.bit.ACTIVEWAIT = 0x01FF;
//Force a pipeline flush to ensure that the write to
//the last register configured occurs before returning.
__asm(” RPT #7 || NOP”);
- Make sure to allocate memory for flashing program, check the linker F28035.cmd, and see whether the line below has been written
ramfuncs : LOAD = FLASHA,
RUN = RAML0,
PAGE = 0
LOAD is the place where the .text section was programmed
Run is the RAM section where the code to be loaded
MemCopy fuction will then copy the code from FLASH to RAM as defined with these symbols.
- Debug to check!