Hi,
I have been working on the C2000 LaunchPad XL with the TMS320F28027 MCU. I am trying to understand completely how to run the chip stand alone booting from flash. I have it mostly figured out.
- I am using F2802x_CodeStartBranch.asm and F28027.cmd in my project.
- I am also copying ram functions to ram as shown below:
#include "F2802x_Device.h"
#pragma CODE_SECTION(flash_config, "ramfuncs");
#pragma CODE_SECTION(isr_timer_0, "ramfuncs");
...
void flash_config(void);
...
extern unsigned short RamfuncsLoadStart;
extern unsigned short RamfuncsLoadSize;
extern unsigned short RamfuncsRunStart;
...
int main(void)
{
unsigned short temp;
memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
flash_config();
...
- I am configuring the clock for 60MHz in the code.
This all works fine when running from CCS Debug. If I reset from the Debug menu and start over or disconnect and run stand alone, the clock I see on the oscilloscope is 12 times slower (5MHz). I do not understand what the difference is. I also have a timer running to blink the LEDs on the board and this timer also runs slower. What is happening? How can I get 60 MHz stand alone booting from flash?
void flash_config(void)
{
unsigned short temp;
EALLOW;
FlashRegs.FOPT.bit.ENPIPE = 1; // enable flash pipeline
temp = FlashRegs.FBANKWAIT.all; // set flash wait state
temp &= ~0x0F0F;
temp |= 0x0202;
FlashRegs.FBANKWAIT.all = temp;
temp = FlashRegs.FOTPWAIT.all; // set OTP wait state
temp &= ~0x001F;
temp |= 0x0002;
FlashRegs.FOTPWAIT.all = temp;
EDIS;
//Force a pipeline flush to ensure that the write to
//the last register configured occurs before returning.
asm(" RPT #7 || NOP");
}
void clock_config(void)
{
// set PLL for 60MHz
SysCtrlRegs.PLLSTS.bit.DIVSEL = 0x3;
SysCtrlRegs.PLLCR.bit.DIV = 0xC;
EDIS;
// wait for PLL to stabilize
while( SysCtrlRegs.PLLSTS.bit.PLLLOCKS == 0 );
EALLOW;
SysCtrlRegs.PLLSTS.bit.DIVSEL = 0x2;
EDIS;
}