I am attempting to port an application from RAM to flash fora TMS320F2812, using CCSv4 and want to understand theprogramming of the flash registers better than on my lastpass. Document SPRA958K provides a function to initializethese registers on page 13:> > /********************************************************************> * NOTE: The InitFlash() function shown here is just an example of an> * initialization for the flash control registers. Consult the device> * datasheet for production wait state values and any other relevant> * information. Wait-states shown here are specific to current F280x> * devices operating at 100 MHz.> * NOTE: This function assumes use of the Peripheral Header File> * structures (see References [23-29]).> ********************************************************************/> > #pragma CODE_SECTION(InitFlash, "secureRamFuncs")> void InitFlash(void)> {> asm(" EALLOW"); // Enable EALLOW protected register access> FlashRegs.FPWR.bit.PWR = 3; // Flash set to active mode> FlashRegs.FSTATUS.bit.V3STAT = 1; // Clear the 3VSTAT bit> FlashRegs.FSTDBYWAIT.bit.STDBYWAIT = 0x01FF; // Sleep to standby cycles> FlashRegs.FACTIVEWAIT.bit.ACTIVEWAIT = 0x01FF; // Standby to active cycles> FlashRegs.FBANKWAIT.bit.RANDWAIT = 3; // F280x Random access wait states> FlashRegs.FBANKWAIT.bit.PAGEWAIT = 3; // F280x Paged access wait states> FlashRegs.FOTPWAIT.bit.OTPWAIT = 5; // F280x OTP wait states> 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 #6 || NOP"); // Takes 8 cycles to execute> } //end of InitFlash()> Note that the comment which precedes the function completelydisclaims its functionality on the F2812.
The register block "FlashRegs" is defined in headerDSP281x_SysCtrl.h, but it tells me nothing about what thosebits do. I can find no mention of these registers in anyreference guide or other support document available on theTI web site.
Assuming I find a performance problem with my flash and wantto optimize the wait states for the F2812, where to I getthe info necessary to do so?
============================================================Gary Lynch printf("lynchg%cstacoenergy%ccom", 55+9, 55-9)============================================================
Gary,
The disclaimer is to let the user know that the wait-states in the example is assumed for 100MHz system frequency. The comment basically asks the user to modify the wait-state as per device frequency.
You can refer to section 1.3 of the F281x System control guide for the Flash and OTP registers which has the register description. Here's the link : http://www.ti.com/lit/ug/spru078f/spru078f.pdf
Regarding the waitstate setting as per system frequency , please refer to Section 6.31, Flash timing section of the data sheet. http://www.ti.com/lit/ds/symlink/sm320f2812.pdf
-Vaish
If a post answers your question, please mark it with the "Verify Answer" button
Would you believe I actually scanned both those documentsand missed the sections you cited?
I am running at 150 MHz, rather than 100. The data sheetactually has a table on page 157 with a plethora of waitstate values for many clock frequencies, leading me toconclude I only need to change 3 statements from the code Iposted:> > FlashRegs.FBANKWAIT.bit.RANDWAIT = 5;> FlashRegs.FBANKWAIT.bit.PAGEWAIT = 5;> FlashRegs.FOTPWAIT.bit.OTPWAIT = 8;> to conform to my project settings.
Thanks for the pointers.
Sure. It tends to happen.
Glad you were able to resolve this issue.