This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Error: No source available for "0x3ff599"

Other Parts Discussed in Thread: CONTROLSUITE

Hi,

 

I am working with a TI 28035 microcontroller on a resolver development board. I was experimenting to change the included code by deleting a background loop which I do not need.

This try led to the error "No source available for "0x3ff599"" as I tried to debug the program. The build process finished without issues.

The problem seems to be the following:

void (*Alpha_State_Ptr)(void);

void main(void)
{
// initialisations etc.

Alpha_State_Ptr = &GO;

// miscellaneous

for(;;)
{
(*Alpha_State_Ptr)();
}

}

void GO(void)
{
}


The code above had been extremely shortened, but this version worked without errors. When I delete the command in the for-loop or replace it with

GO();

then the debug error occurs.

 

I have absolutely no idea what the problem could be. I'd be happy about suggestions.

Thank's in advance.

 

PS: Pressing the green debug arrow again or resetting/restarting the uC didn't help.

  • Brian,

    This is not a code execution error, but rather a CCS "Message". CCS is just saying that it doesn't have source code for the address at which you have stopped the processor, so it cannot show you the source code (you need to look at the disassembly). Address 0x3FF599 is in the ROM. I don't know what you function GO() does, but it seems to be calling some function in the ROM. When you halt and the PC is pointing at the ROM function, CCS cannot pull up the source code.

    You can actually get the source files for the ROM in ControlSuite (here: C:\TI\controlSUITE\libs\utilities\boot_rom\2803x). You can then load the symbols (.out file) and debug problems that you have with the ROM functions.

    Regards,
    David
  • Hi David, thank you for the reply !

    The function GO() is empty. This is why for me there is no difference if I delete the

    (*Alpha_State_Ptr)();

    but obviously I am wrong.

     

    You can actually get the source files for the ROM in ControlSuite (here: C:\TI\controlSUITE\libs\utilities\boot_rom\2803x).  You can then load the symbols (.out file) and debug problems that you have with the ROM functions.

     

    Could you explain what I should do to successfully debug the program and run it on the uC ?

    I found the file "TMS320x2803x_boot_rom.out" in C:\TI\controlSUITE\libs\utilities\boot_rom\2803x\2803x_boot_rom_v1_Release. Unfortunately I don't know what I should do with it.

     

     Can you give me a hint ? Thanks.

     

  • Brian,

    I think I understand what you are doing better now.  I missed the empty GO() function before.

    The problem is not the ROM, so I think you can forget about debugging the ROM.  The problem seems to be why your PC is changing to 0x3FF599 (for example) in the first place.

    I would step through your main() and see what is happening when you get near/to your for(;;) loop.  If I understand you correctly, you're saying that things work OK for this loop:

    for(;;)
    {
      (*Alpha_State_Ptr)();
    }

    but if you do this your PC goes off to 0x3FF599?

    for(;;)
    {
      GO();
    }
    Just thinking out loud - Did you function prototype GO()?
    - David

  • Hi David,

    I'm sorry, the code in the first post was not complete. This is what I tried (change in line 1).

    void GO(void);
    void (*Alpha_State_Ptr)(void);
    
    void main(void)
    {
    // initialisations etc.
    
    Alpha_State_Ptr = &GO;
    
    // miscellaneous
    
    for(;;)
    {
    (*Alpha_State_Ptr)();
    }
    
    }
    
    void GO(void)
    {
    }
    


    Replacing

    (*Alpha_State_Ptr)();

    by GO(); or deleting this line completely leads to the error.

    - Brian

  • Brian,

    You have something else going on in your code. What your saying is that if you delete the line completely and leave just the endless for(;;) loop, you halt the debugger and there is no source code available (hence the debugger error message about no source code).

    Do you have interrupts being serviced?

    Did you disable the watchdog timer?

    Is your code working correctly? Remember the debugger message about no source available is not necessarily indicative of a problem.

    - David
  • I think I could localize the error, but I was not able to solve it yet.

    I am using an external interrupt. For initialisation I execute the following code in the main function.

    EALLOW;
    
    GpioIntRegs.GPIOXINT1SEL.bit.GPIOSEL = 9;  // XINT1 is GPIO9
    XIntruptRegs.XINT1CR.bit.POLARITY = 0;     // Falling edge Interrupt
    XIntruptRegs.XINT1CR.bit.ENABLE = 1;       // Enable XINT1
    PieCtrlRegs.PIEIER1.bit.INTx4 = 1;         // Enable PIE Group 1 INT4
    PieVectTable.XINT1 = &xint1_isr;           // Assign XINT1 ISR
    IER |= M_INT1;                             // Enable CPU INT1
    
    EINT;
    ERTM;
    EDIS;


    I tried it with an empty ISR.

    #pragma CODE_SECTION(xint1_isr,"ramfuncs");
    Interrupt void xint1_isr(void)
    {
    return;
    }

    Yes, there is a prototype for this ISR function.
    If I try to debug (with an empty endless for(;;) loop), the known error occurs. When I comment out the line

    PieVectTable.XINT1 = &xint1_isr;           // Assign XINT1 ISR

    in the initialisiation, the debugging works.

    Any suggestions ?

    - Brian 

    PS: Yes, the watchdog is disabled.

    Edit:

    The Debugger stops with the code "ESTOP0". I found the following function in "Resolver-DevInit_F2803x.c".

    interrupt void ISR_ILLEGAL(void)   // Illegal Operation TRAP
    {
       // Insert ISR Code here
    
       // Next two lines for debug only to halt the processor here
       // Remove after inserting ISR Code
       asm("        ESTOP0");
       for(;;);
    }

    But even after commenting out this occurence of the "ESTOP0" command and a second one in the same file, the error still exists...

  • You have two different issues here.  The debugger error message is what we've been discussing.  This is not necessarily an "Error" as I've stated.  There is no reason why having an empty endless for() loop versus putting a call to a dummy function in the for() loop should make any difference in this regard.  I would suggest forgetting about this for now.

    The other issue you have is the illegal ISR trap.  You have your XINT1 ISR in the section "ramfuncs".  I assume you have this section linked to load to flash but run from RAM.  Did you actually copy the section to RAM as part of your initialization?  If you didn't, that would be why you're getting the illegal ISR when the interrupt fires.

    - David

  • I did this, because that's how it was done in the sample code.

    When I delete the #pragma line, the error still occurs.

    I am not sure if that is what you meant.

    - Brian

    Edit:

    Choosing F2803x RAM as the active build configuration, the debugging works. My project uses the InitFlash() and MemCopy() functions and settings from the TI_Resolver_f28035 example project.

    Did I forget something for running in Flash ? 

  • Brian,

    It sounds like you did not link something correctly, or did not do the memory copy right. Suggest reading appnote SPRA958 and cross-checking against your project.

    www.ti.com/.../litabsmultiplefilelist.tsp


    Regards,
    David
  • Hi David,

    I tried it with a minimal soluation. I deleted every RAM/Flash/Copy code:

    #include "PeripheralHeaderIncludes.h"
    
    __interrupt void xint1_isr(void);
    
    int main(void) {
    	
    	DeviceInit();	// Device Life support & GPIO
    
        EALLOW;// This is needed to write to EALLOW protected registers
    
        GpioCtrlRegs.GPAQSEL1.bit.GPIO9 = 0;
    
        PieVectTable.XINT1 = &xint1_isr; 			// Assign XINT1 ISR
        PieCtrlRegs.PIEIER1.bit.INTx4 = 1;          // Enable PIE Group 1 INT4
        GpioIntRegs.GPIOXINT1SEL.bit.GPIOSEL = 9;   // XINT1 is GPIO9
        XIntruptRegs.XINT1CR.bit.POLARITY = 0;      // Falling edge interrupt
        XIntruptRegs.XINT1CR.bit.ENABLE = 1;        // Enable XINT1
        IER |= M_INT1;                              // Enable CPU INT1
    
        // Enable global Interrupts and higher priority real-time debug events:
        EINT;   // Enable Global interrupt INTM
        ERTM;	// Enable Global realtime interrupt DBGM
    
        EDIS;
    
        for(;;)  //infinite loop
        {
        }
    }
    
    __interrupt void xint1_isr(void)
    {
    	PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
    }


    The DeviceInit() is defined in the "Resolver-DevInit_F2803x.c":

    //----------------------------------------------------------------------------------
    //
    // FILE:	{ProjectName}-DevInit_F2803x.c
    //
    // DESCRIPTION:	Device initialization for F2803x series
    // 
    //----------------------------------------------------------------------------------
    //  Copyright Texas Instruments © 2010
    //----------------------------------------------------------------------------------
    //  Revision History:
    //----------------------------------------------------------------------------------
    //  Date	  | Description / Status
    //----------------------------------------------------------------------------------
    //
    //----------------------------------------------------------------------------------
    
    #include "PeripheralHeaderIncludes.h"
    
    // Functions that will be run from RAM need to be assigned to
    // a different section.  This section will then be mapped to a load and
    // run address using the linker cmd file
    #pragma CODE_SECTION(InitFlash, "ramfuncs");
    #define Device_cal (void   (*)(void))0x3D7C80
    
    void DeviceInit(void);
    void PieCntlInit(void);
    void PieVectTableInit(void);
    void WDogDisable(void);
    void PLLset(Uint16);
    void ISR_ILLEGAL(void);
    void MemCopy(Uint16 *SourceAddr, Uint16* SourceEndAddr, Uint16* DestAddr);
    
    //--------------------------------------------------------------------
    //  Configure Device for target Application Here
    //--------------------------------------------------------------------
    void DeviceInit(void)
    {
    	WDogDisable(); 	// Disable the watchdog initially
    	DINT;			// Global Disable all Interrupts
    	IER = 0x0000;	// Disable CPU interrupts
    	IFR = 0x0000;	// Clear all CPU interrupt flags=
    	PieCntlInit();
    	PieVectTableInit();
    
    
    // Switch to Internal Oscillator 1 and turn off all other clock
    // sources to minimize power consumption
    	EALLOW;
    	SysCtrlRegs.CLKCTL.bit.INTOSC1OFF = 0;
        SysCtrlRegs.CLKCTL.bit.OSCCLKSRCSEL=0;  // Clk Src = INTOSC1
    	SysCtrlRegs.CLKCTL.bit.XCLKINOFF=1;     // Turn off XCLKIN
    	SysCtrlRegs.CLKCTL.bit.XTALOSCOFF=1;    // Turn off XTALOSC
    	SysCtrlRegs.CLKCTL.bit.INTOSC2OFF=1;    // Turn off INTOSC2
        EDIS;
    
    
    // SYSTEM CLOCK speed based on internal oscillator = 10 MHz
    // 0xC =  60	MHz		(12)
    // 0xB =  55	MHz		(11)
    // 0xA =  50	MHz		(10)
    // 0x9 =  45	MHz		(9)
    // 0x8 =  40	MHz		(8)
    // 0x7 =  35	MHz		(7)
    // 0x6 =  30	MHz		(6)
    // 0x5 =  25	MHz		(5)
    // 0x4 =  20	MHz		(4)
    // 0x3 =  15	MHz		(3)
    // 0x2 =  10	MHz		(2)
    
    	PLLset(0xC);	// choose from options above
    
    // Initialise interrupt controller and Vector Table
    // to defaults for now. Application ISR mapping done later.
    //	PieCntlInit();		
    //	PieVectTableInit();
    
       EALLOW; // below registers are "protected", allow access.
    
    // LOW SPEED CLOCKS prescale register settings
       SysCtrlRegs.LOSPCP.all = 0x0003;		// Sysclk / 4 (15 MHz)
       SysCtrlRegs.XCLK.bit.XCLKOUTDIV=2;
          
          
    // ADC CALIBRATION 
    //---------------------------------------------------
    // The Device_cal function, which copies the ADC & oscillator calibration values
    // from TI reserved OTP into the appropriate trim registers, occurs automatically
    // in the Boot ROM. If the boot ROM code is bypassed during the debug process, the
    // following function MUST be called for the ADC and oscillators to function according
    // to specification.
    
    	SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1; // Enable ADC peripheral clock
    	(*Device_cal)();					  // Auto-calibrate from TI OTP
    	SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 0; // Return ADC clock to original state     
    
          	
    // PERIPHERAL CLOCK ENABLES 
    //---------------------------------------------------
    // If you are not using a peripheral you may want to switch
    // the clock off to save power, i.e. set to =0 
    // 
    // Note: not all peripherals are available on all 280x derivates.
    // Refer to the datasheet for your particular device. 
    
       SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;    // ADC
       //------------------------------------------------
       SysCtrlRegs.PCLKCR3.bit.COMP1ENCLK = 0;	// COMP1
       SysCtrlRegs.PCLKCR3.bit.COMP2ENCLK = 0;	// COMP2
       SysCtrlRegs.PCLKCR3.bit.COMP3ENCLK = 0;  // COMP3
       //------------------------------------------------
       SysCtrlRegs.PCLKCR1.bit.ECAP1ENCLK = 0;	//eCAP1
       //------------------------------------------------
       SysCtrlRegs.PCLKCR0.bit.ECANAENCLK= 0;   // eCAN-A
       //------------------------------------------------
       SysCtrlRegs.PCLKCR1.bit.EQEP1ENCLK = 0;  // eQEP1
       //------------------------------------------------
       SysCtrlRegs.PCLKCR1.bit.EPWM1ENCLK = 1;  // ePWM1
       SysCtrlRegs.PCLKCR1.bit.EPWM2ENCLK = 1;  // ePWM2
       SysCtrlRegs.PCLKCR1.bit.EPWM3ENCLK = 1;  // ePWM3   // pwm dac
       SysCtrlRegs.PCLKCR1.bit.EPWM4ENCLK = 1;  // ePWM4   // pwm dac
       SysCtrlRegs.PCLKCR1.bit.EPWM5ENCLK = 0;	// ePWM5
       SysCtrlRegs.PCLKCR1.bit.EPWM6ENCLK = 0;	// ePWM6
       SysCtrlRegs.PCLKCR1.bit.EPWM7ENCLK = 0;	// ePWM7
       SysCtrlRegs.PCLKCR0.bit.HRPWMENCLK = 0;  // HRPWM
       //------------------------------------------------
       SysCtrlRegs.PCLKCR0.bit.I2CAENCLK = 0;   // I2C
       //------------------------------------------------
       SysCtrlRegs.PCLKCR0.bit.LINAENCLK = 0;   // LIN-A
       //------------------------------------------------
       SysCtrlRegs.PCLKCR3.bit.CLA1ENCLK = 0;   // CLA1
       //------------------------------------------------
       SysCtrlRegs.PCLKCR0.bit.SCIAENCLK = 0;  	// SCI-A
       //------------------------------------------------
       SysCtrlRegs.PCLKCR0.bit.SPIAENCLK = 1;	// SPI-A
       SysCtrlRegs.PCLKCR0.bit.SPIBENCLK = 0;   // SPI-B
       //------------------------------------------------
       SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;   // Enable TBCLK
       //------------------------------------------------           
    
                                   
    //--------------------------------------------------------------------------------------
    // GPIO (GENERAL PURPOSE I/O) CONFIG
    //--------------------------------------------------------------------------------------
    //-----------------------
    // QUICK NOTES on USAGE:
    //-----------------------
    // If GpioCtrlRegs.GP?MUX?bit.GPIO?= 1, 2 or 3 (i.e. Non GPIO func), then leave
    //	rest of lines commented
    // If GpioCtrlRegs.GP?MUX?bit.GPIO?= 0 (i.e. GPIO func), then:
    //	1) uncomment GpioCtrlRegs.GP?DIR.bit.GPIO? = ? and choose pin to be IN or OUT
    //	2) If IN, can leave next to lines commented
    //	3) If OUT, uncomment line with ..GPACLEAR.. to force pin LOW or
    //			   uncomment line with ..GPASET.. to force pin HIGH or
    //--------------------------------------------------------------------------------------
    //--------------------------------------------------------------------------------------
    //  GPIO-00 - PIN FUNCTION = PWM1A
    	GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0;		// 0=GPIO,  1=EPWM1A,  2=Resv,  3=Resv
    	GpioCtrlRegs.GPADIR.bit.GPIO0 = 0;		// 1=OUTput,  0=INput
    	GpioDataRegs.GPACLEAR.bit.GPIO0 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO0 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-01 - PIN FUNCTION = PWM1B    - reveal timing associated with EPWM1
    	GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1;		// 0=GPIO,  1=EPWM1B,  2=Resv,  3=COMP1OUT
    	GpioCtrlRegs.GPADIR.bit.GPIO1 = 1;		// 1=OUTput,  0=INput 
    	GpioDataRegs.GPACLEAR.bit.GPIO1 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO1 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-02 - PIN FUNCTION = PWM2A    - Sine wave generation
    	GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 1;		// 0=GPIO,  1=EPWM2A,  2=Resv,  3=Resv
    //	GpioCtrlRegs.GPADIR.bit.GPIO2 = 0;		// 1=OUTput,  0=INput 
    //	GpioDataRegs.GPACLEAR.bit.GPIO2 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO2 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-03 - PIN FUNCTION = PWM2B    - Sine wave dithering - not used
    	GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 0;		// 0=GPIO,  1=EPWM2B,  2=SPISOMI-A,  3=COMP2OUT
    	GpioCtrlRegs.GPADIR.bit.GPIO3 = 1;		// 1=OUTput,  0=INput
    	GpioDataRegs.GPACLEAR.bit.GPIO3 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO3 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-04 - PIN FUNCTION = PWM3A      - PWMDAC
    	GpioCtrlRegs.GPAMUX1.bit.GPIO4 = 1;		// 0=GPIO,  1=EPWM3A,  2=Resv,  3=Resv
    //	GpioCtrlRegs.GPADIR.bit.GPIO4 = 0;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPACLEAR.bit.GPIO4 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO4 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-05 - PIN FUNCTION = PWM3B      - PWMDAC
    	GpioCtrlRegs.GPAMUX1.bit.GPIO5 = 1;		// 0=GPIO,  1=EPWM3B,  2=SPISIMO-A,  3=ECAP1
    //	GpioCtrlRegs.GPADIR.bit.GPIO5 = 0;		// 1=OUTput,  0=INput 
    //	GpioDataRegs.GPACLEAR.bit.GPIO5 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO5 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-06 - PIN FUNCTION = PWM4A      - PWMDAC
    	GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 1;		// 0=GPIO,  1=EPWM4A,  2=SYNCI,  3=SYNCO
    //	GpioCtrlRegs.GPADIR.bit.GPIO6 = 0;		// 1=OUTput,  0=INput 
    //	GpioDataRegs.GPACLEAR.bit.GPIO6 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO6 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-07 - PIN FUNCTION = PWM4B      - PWMDAC
    	GpioCtrlRegs.GPAMUX1.bit.GPIO7 = 1;		// 0=GPIO,  1=EPWM4B,  2=SCIRX-A,  3=Resv
    //	GpioCtrlRegs.GPADIR.bit.GPIO7 = 0;		// 1=OUTput,  0=INput 
    //	GpioDataRegs.GPACLEAR.bit.GPIO7 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO7 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-08 - PIN FUNCTION = PWM5A
    	GpioCtrlRegs.GPAMUX1.bit.GPIO8 = 0;		// 0=GPIO,  1=EPWM5A,  2=Resv,  3=ADCSOC-A
    //	GpioCtrlRegs.GPADIR.bit.GPIO8 = 0;		// 1=OUTput,  0=INput 
    //	GpioDataRegs.GPACLEAR.bit.GPIO8 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO8 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-09 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 0;		// 0=GPIO,  1=EPWM5B,  2=LINTX-A,  3=Resv
    	GpioCtrlRegs.GPADIR.bit.GPIO9 = 0;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPACLEAR.bit.GPIO9 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO9 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-10 - PIN FUNCTION = PWM6A
    	GpioCtrlRegs.GPAMUX1.bit.GPIO10 = 0;	// 0=GPIO,  1=EPWM6A,  2=Resv,  3=ADCSOC-B
    //	GpioCtrlRegs.GPADIR.bit.GPIO10 = 0;		// 1=OUTput,  0=INput 
    //	GpioDataRegs.GPACLEAR.bit.GPIO10 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO10 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-11 - PIN FUNCTION = GPIO - OUTPUT -- flagging
    	GpioCtrlRegs.GPAMUX1.bit.GPIO11 = 0;	// 0=GPIO,  1=EPWM6B,  2=LINRX-A,  3=Resv
    	GpioCtrlRegs.GPADIR.bit.GPIO11 = 1;		// 1=OUTput,  0=INput 
    //	GpioDataRegs.GPACLEAR.bit.GPIO11 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO11 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-12 - PIN FUNCTION = IPM Fault Trip Zone Protection
    	GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 0;	// 0=GPIO,  1=TZ1,  2=SCITX-A,  3=SPISIMO-B
    //	GpioCtrlRegs.GPADIR.bit.GPIO12 = 0;		// 1=OUTput,  0=INput 
    //	GpioDataRegs.GPACLEAR.bit.GPIO12 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO12 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-13 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPAMUX1.bit.GPIO13 = 0;	// 0=GPIO,  1=TZ2,  2=Resv,  3=SPISOMI-B
    //	GpioCtrlRegs.GPADIR.bit.GPIO13 = 0;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPACLEAR.bit.GPIO13 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO13 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-14 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPAMUX1.bit.GPIO14 = 0;	// 0=GPIO,  1=TZ3,  2=LINTX-A,  3=SPICLK-B
    //	GpioCtrlRegs.GPADIR.bit.GPIO14 = 0;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPACLEAR.bit.GPIO14 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO14 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-15 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPAMUX1.bit.GPIO15 = 0;	// 0=GPIO,  1=TZ1,  2=LINRX-A,  3=SPISTE-B
    //	GpioCtrlRegs.GPADIR.bit.GPIO15 = 0;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPACLEAR.bit.GPIO15 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO15 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //--------------------------------------------------------------------------------------
    //  GPIO-16 - PIN FUNCTION = SPISIMO-A
    	GpioCtrlRegs.GPAMUX2.bit.GPIO16 = 1;	// 0=GPIO,  1=SPISIMO-A,  2=Resv,  3=TZ2
    //	GpioCtrlRegs.GPADIR.bit.GPIO16 = 1;		// 1=OUTput,  0=INput 
    //	GpioDataRegs.GPACLEAR.bit.GPIO16 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO16 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-17 - PIN FUNCTION = SPISOMI-A
    	GpioCtrlRegs.GPAMUX2.bit.GPIO17 = 1;	// 0=GPIO,  1=SPISOMI-A,  2=Resv,  3=TZ3
    //	GpioCtrlRegs.GPADIR.bit.GPIO17 = 1;		// 1=OUTput,  0=INput 
    //	GpioDataRegs.GPACLEAR.bit.GPIO17 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO17 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-18 - PIN FUNCTION = SPICLK-A
    	GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 1;	// 0=GPIO,  1=SPICLK-A,  2=LINTX-A,  3=XCLKOUT
    //	GpioCtrlRegs.GPADIR.bit.GPIO18 = 1;		// 1=OUTput,  0=INput 
    //	GpioDataRegs.GPACLEAR.bit.GPIO18 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO18 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-19 - PIN FUNCTION = SPISTE-A
    	GpioCtrlRegs.GPAMUX2.bit.GPIO19 = 1;	// 0=GPIO,  1=SPISTE-A,  2=LINRX-A,  3=ECAP1
    //	GpioCtrlRegs.GPADIR.bit.GPIO19 = 1;		// 1=OUTput,  0=INput 
    //	GpioDataRegs.GPACLEAR.bit.GPIO19 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO19 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-20 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPAMUX2.bit.GPIO20 = 0;	// 0=GPIO,  1=EQEPA-1,  2=Resv,  3=COMP1OUT
    //	GpioCtrlRegs.GPADIR.bit.GPIO20 = 0;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPACLEAR.bit.GPIO20 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO20 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-21 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPAMUX2.bit.GPIO21 = 0;	// 0=GPIO,  1=EQEPB-1,  2=Resv,  3=COMP2OUT
    //	GpioCtrlRegs.GPADIR.bit.GPIO21 = 0;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPACLEAR.bit.GPIO21 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO21 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-22 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPAMUX2.bit.GPIO22 = 0;	// 0=GPIO,  1=EQEPS-1,  2=Resv,  3=LINTX-A
    //	GpioCtrlRegs.GPADIR.bit.GPIO22 = 0;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPACLEAR.bit.GPIO22 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO22 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-23 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPAMUX2.bit.GPIO23 = 0;	// 0=GPIO,  1=EQEPI-1,  2=Resv,  3=LINRX-A
    //	GpioCtrlRegs.GPADIR.bit.GPIO23 = 0;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPACLEAR.bit.GPIO23 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO23 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-24 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPAMUX2.bit.GPIO24 = 0;	// 0=GPIO,  1=ECAP1,  2=Resv,  3=SPISIMO-B
    //	GpioCtrlRegs.GPADIR.bit.GPIO24 = 0;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPACLEAR.bit.GPIO24 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO24 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-25 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPAMUX2.bit.GPIO25 = 0;	// 0=GPIO,  1=Resv,  2=Resv,  3=SPISOMI-B
    //	GpioCtrlRegs.GPADIR.bit.GPIO25 = 0;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPACLEAR.bit.GPIO25 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO25 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-26 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPAMUX2.bit.GPIO26 = 0;	// 0=GPIO,  1=Resv,  2=Resv,  3=SPICLK-B
    //	GpioCtrlRegs.GPADIR.bit.GPIO26 = 0;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPACLEAR.bit.GPIO26 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO26 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-27 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPAMUX2.bit.GPIO27 = 0;	// 0=GPIO,  1=Resv,  2=Resv,  3=SPISTE-B
    //	GpioCtrlRegs.GPADIR.bit.GPIO27 = 0;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPACLEAR.bit.GPIO27 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO27 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-28 - PIN FUNCTION = SCI-RX
    	GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 1;	// 0=GPIO,  1=SCIRX-A,  2=I2CSDA-A,  3=TZ2
    //	GpioCtrlRegs.GPADIR.bit.GPIO28 = 1;		// 1=OUTput,  0=INput 
    //	GpioDataRegs.GPACLEAR.bit.GPIO28 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO28 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-29 - PIN FUNCTION = SCI-TX
    	GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 1;	// 0=GPIO,  1=SCITXD-A,  2=I2CSCL-A,  3=TZ3
    //	GpioCtrlRegs.GPADIR.bit.GPIO29 = 0;		// 1=OUTput,  0=INput 
    //	GpioDataRegs.GPACLEAR.bit.GPIO29 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO29 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-30 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPAMUX2.bit.GPIO30 = 0;	// 0=GPIO,  1=CANRX-A,  2=Resv,  3=Resv
    //	GpioCtrlRegs.GPADIR.bit.GPIO30 = 1;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPACLEAR.bit.GPIO30 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO30 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-31 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPAMUX2.bit.GPIO31 = 0;	// 0=GPIO,  1=CANTX-A,  2=Resv,  3=Resv
    //	GpioCtrlRegs.GPADIR.bit.GPIO31 = 1;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPACLEAR.bit.GPIO31 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPASET.bit.GPIO31 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //--------------------------------------------------------------------------------------
    //  GPIO-32 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 0;	// 0=GPIO,  1=I2CSDA-A,  2=SYNCI,  3=ADCSOCA
    	GpioCtrlRegs.GPBDIR.bit.GPIO32 = 1;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPBCLEAR.bit.GPIO32 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPBSET.bit.GPIO32 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-33 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 0;	// 0=GPIO,  1=I2CSCL-A,  2=SYNCO,  3=ADCSOCB
    //	GpioCtrlRegs.GPBDIR.bit.GPIO33 = 1;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPBCLEAR.bit.GPIO33 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPBSET.bit.GPIO33 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-34 - PIN FUNCTION = -- LED3 --
    	GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0;	// 0=GPIO,  1=Resv,  2=Resv,  3=Resv
    	GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPBCLEAR.bit.GPIO34 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPBSET.bit.GPIO34 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //--------------------------------------------------------------------------------------
    // GPIO 35-38 are defaulted to JTAG usage, and are not shown here to enforce JTAG debug
    // usage. 
    //--------------------------------------------------------------------------------------
    //--------------------------------------------------------------------------------------
    //  GPIO-39 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPBMUX1.bit.GPIO39 = 0;	// 0=GPIO,  1=Resv,  2=Resv,  3=Resv
    //	GpioCtrlRegs.GPBDIR.bit.GPIO39 = 0;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPBCLEAR.bit.GPIO39 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPBSET.bit.GPIO39 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-40 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPBMUX1.bit.GPIO40 = 0;	// 0=GPIO,  1=EPWM7A,  2=Resv,  3=Resv
    	//GpioCtrlRegs.GPBDIR.bit.GPIO40 = 0;		// 1=OUTput,  0=INput 
    //	GpioDataRegs.GPBCLEAR.bit.GPIO40 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPBSET.bit.GPIO40 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-41 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPBMUX1.bit.GPIO41 = 0;	// 0=GPIO,  1=EPWM7B,  2=Resv,  3=Resv
    //	GpioCtrlRegs.GPBDIR.bit.GPIO41 = 0;		// 1=OUTput,  0=INput 
    //	GpioDataRegs.GPBCLEAR.bit.GPIO41 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPBSET.bit.GPIO41 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-42 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPBMUX1.bit.GPIO42 = 1;	// 0=GPIO,  1=Resv,  2=Resv,  3=COMP1OUT
    //	GpioCtrlRegs.GPBDIR.bit.GPIO42 = 0;		// 1=OUTput,  0=INput 
    //	GpioDataRegs.GPBCLEAR.bit.GPIO42 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPBSET.bit.GPIO42 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-43 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPBMUX1.bit.GPIO43 = 0;	// 0=GPIO,  1=Resv,  2=Resv,  3=COMP2OUT
    //	GpioCtrlRegs.GPBDIR.bit.GPIO43 = 0;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPBCLEAR.bit.GPIO43 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPBSET.bit.GPIO43 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //  GPIO-44 - PIN FUNCTION = --Spare--
    	GpioCtrlRegs.GPBMUX1.bit.GPIO44 = 0;	// 0=GPIO,  1=Resv,  2=Resv,  3=Resv
    //	GpioCtrlRegs.GPBDIR.bit.GPIO44 = 0;		// 1=OUTput,  0=INput
    //	GpioDataRegs.GPBCLEAR.bit.GPIO44 = 1;	// uncomment if --> Set Low initially
    //	GpioDataRegs.GPBSET.bit.GPIO44 = 1;		// uncomment if --> Set High initially
    //--------------------------------------------------------------------------------------
    //--------------------------------------------------------------------------------------
    	EDIS;	// Disable register access
    }
    
    //============================================================================
    // NOTE:
    // IN MOST APPLICATIONS THE FUNCTIONS AFTER THIS POINT CAN BE LEFT UNCHANGED
    // THE USER NEED NOT REALLY UNDERSTAND THE BELOW CODE TO SUCCESSFULLY RUN THIS
    // APPLICATION.
    //============================================================================
    
    void WDogDisable(void)
    {
        EALLOW;
        SysCtrlRegs.WDCR= 0x0068;
        EDIS;
    }
    
    // This function initializes the PLLCR register.
    //void InitPll(Uint16 val, Uint16 clkindiv)
    void PLLset(Uint16 val)
    {
       volatile Uint16 iVol;
    
       // Make sure the PLL is not running in limp mode
       if (SysCtrlRegs.PLLSTS.bit.MCLKSTS != 0)
       {
    	  EALLOW;
          // OSCCLKSRC1 failure detected. PLL running in limp mode.
          // Re-enable missing clock logic.
          SysCtrlRegs.PLLSTS.bit.MCLKCLR = 1;
          EDIS;
          // Replace this line with a call to an appropriate
          // SystemShutdown(); function.
          asm("        ESTOP0");     // Uncomment for debugging purposes
       }
    
       // DIVSEL MUST be 0 before PLLCR can be changed from
       // 0x0000. It is set to 0 by an external reset XRSn
       // This puts us in 1/4
       if (SysCtrlRegs.PLLSTS.bit.DIVSEL != 0)
       {
           EALLOW;
           SysCtrlRegs.PLLSTS.bit.DIVSEL = 0;
           EDIS;
       }
    
       // Change the PLLCR
       if (SysCtrlRegs.PLLCR.bit.DIV != val)
       {
    
          EALLOW;
          // Before setting PLLCR turn off missing clock detect logic
          SysCtrlRegs.PLLSTS.bit.MCLKOFF = 1;
          SysCtrlRegs.PLLCR.bit.DIV = val;
          EDIS;
    
          // Optional: Wait for PLL to lock.
          // During this time the CPU will switch to OSCCLK/2 until
          // the PLL is stable.  Once the PLL is stable the CPU will
          // switch to the new PLL value.
          //
          // This time-to-lock is monitored by a PLL lock counter.
          //
          // Code is not required to sit and wait for the PLL to lock.
          // However, if the code does anything that is timing critical,
          // and requires the correct clock be locked, then it is best to
          // wait until this switching has completed.
    
          // Wait for the PLL lock bit to be set.
          // The watchdog should be disabled before this loop, or fed within
          // the loop via ServiceDog().
    
    	  // Uncomment to disable the watchdog
          WDogDisable();
    
    	  while(SysCtrlRegs.PLLSTS.bit.PLLLOCKS != 1) {}
    
          EALLOW;
          SysCtrlRegs.PLLSTS.bit.MCLKOFF = 0;
    	  EDIS;
    	}
    
    	  //divide down SysClk by 2 to increase stability
    	EALLOW;
    	SysCtrlRegs.PLLSTS.bit.DIVSEL = 2; 
    	EDIS;
    }
    
    
    // This function initializes the PIE control registers to a known state.
    //
    void PieCntlInit(void)
    {
        // Disable Interrupts at the CPU level:
        DINT;
    
        // Disable the PIE
        PieCtrlRegs.PIECTRL.bit.ENPIE = 0;
    
    	// Clear all PIEIER registers:
    	PieCtrlRegs.PIEIER1.all = 0;
    	PieCtrlRegs.PIEIER2.all = 0;
    	PieCtrlRegs.PIEIER3.all = 0;	
    	PieCtrlRegs.PIEIER4.all = 0;
    	PieCtrlRegs.PIEIER5.all = 0;
    	PieCtrlRegs.PIEIER6.all = 0;
    	PieCtrlRegs.PIEIER7.all = 0;
    	PieCtrlRegs.PIEIER8.all = 0;
    	PieCtrlRegs.PIEIER9.all = 0;
    	PieCtrlRegs.PIEIER10.all = 0;
    	PieCtrlRegs.PIEIER11.all = 0;
    	PieCtrlRegs.PIEIER12.all = 0;
    
    	// Clear all PIEIFR registers:
    	PieCtrlRegs.PIEIFR1.all = 0;
    	PieCtrlRegs.PIEIFR2.all = 0;
    	PieCtrlRegs.PIEIFR3.all = 0;	
    	PieCtrlRegs.PIEIFR4.all = 0;
    	PieCtrlRegs.PIEIFR5.all = 0;
    	PieCtrlRegs.PIEIFR6.all = 0;
    	PieCtrlRegs.PIEIFR7.all = 0;
    	PieCtrlRegs.PIEIFR8.all = 0;
    	PieCtrlRegs.PIEIFR9.all = 0;
    	PieCtrlRegs.PIEIFR10.all = 0;
    	PieCtrlRegs.PIEIFR11.all = 0;
    	PieCtrlRegs.PIEIFR12.all = 0;
    }	
    
    
    void PieVectTableInit(void)
    {
    	int16	i;
    	Uint32 *Source = (void *) &ISR_ILLEGAL;
    	Uint32 *Dest = (void *) &PieVectTable;
    		
    	EALLOW;	
    	for(i=0; i < 128; i++)
    		*Dest++ = *Source;	
    	EDIS;
    
    	// Enable the PIE Vector Table
    	PieCtrlRegs.PIECTRL.bit.ENPIE = 1;	
    }
    
    interrupt void ISR_ILLEGAL(void)   // Illegal operation TRAP
    {
      // Insert ISR Code here
    
      // Next two lines for debug only to halt the processor here
      // Remove after inserting ISR Code
      asm("          ESTOP0");
      for(;;);
    
    }
    
    // This function initializes the Flash Control registers
    
    //                   CAUTION
    // This function MUST be executed out of RAM. Executing it
    // out of OTP/Flash will yield unpredictable results
    
    void InitFlash(void)
    {
       EALLOW;
       //Enable Flash Pipeline mode to improve performance
       //of code executed from Flash.
       FlashRegs.FOPT.bit.ENPIPE = 1;
    
       //                CAUTION
       //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 = 3;
    
       //Set the Random Waitstate for the Flash
       FlashRegs.FBANKWAIT.bit.RANDWAIT = 3;
    
       //Set the Waitstate for the OTP
       FlashRegs.FOTPWAIT.bit.OTPWAIT = 5;
    
       //                CAUTION
       //ONLY THE DEFAULT VALUE FOR THESE 2 REGISTERS SHOULD BE USED
       FlashRegs.FSTDBYWAIT.bit.STDBYWAIT = 0x01FF;
       FlashRegs.FACTIVEWAIT.bit.ACTIVEWAIT = 0x01FF;
       EDIS;
    
       //Force a pipeline flush to ensure that the write to
       //the last register configured occurs before returning.
    
       asm(" RPT #7 || NOP");
    }
    
    
    // This function will copy the specified memory contents from
    // one location to another. 
    // 
    //	Uint16 *SourceAddr        Pointer to the first word to be moved
    //                          SourceAddr < SourceEndAddr
    //	Uint16* SourceEndAddr     Pointer to the last word to be moved
    //	Uint16* DestAddr          Pointer to the first destination word
    //
    // No checks are made for invalid memory locations or that the
    // end address is > then the first start address.
    
    void MemCopy(Uint16 *SourceAddr, Uint16* SourceEndAddr, Uint16* DestAddr)
    {
        while(SourceAddr < SourceEndAddr)
        { 
           *DestAddr++ = *SourceAddr++;
        }
        return;
    }
    	
    //===========================================================================
    // End of file.
    //===========================================================================
    


    I do not understand, why the error still occurs. Sorry, I am just starting.

    - Brian

  • Brian,

    When you say "the error still occurs" what error do you mean? Do you mean you get the Illegal ISR interrupt when you try to execute from flash?

    To execute code from flash, you need to manually copy all sections that are linked to load to flash but run from RAM. I don't see this happening in the code you show. The memcopy() function is present, but you have to call it from main(). See appnote SPRA958 as I cited in my previous post.

    - David
  • David M. Alter said:
    When you say "the error still occurs" what error do you mean? Do you mean you get the Illegal ISR interrupt when you try to execute from flash?

    Yes, I mean the ESTOP0 @ 0x3ff599.

     

    I must admit, that I don't quite understand what I need to copy (SPRA958). My goal is, that the µC is able to work standalone and the program is not getting lost on power off.

    In the main() i added the InitFlash() function, as well as adding

    memcpy((Uint16 *)&PieVectTable+6, (Uint16 *)&PieVectTableInit+6, 256-6);

    to the PieCntInit() function. This did not help. I also tried to assign the xint1_isr to "ramfuncs" again and copy the memory content as shown in a post before, without success. There is the "DSP2803x_Headers_nonBIOS.cmd" added to the project too.

     

    Would it be possible to explain in a few words what the necessary steps are ?

    Thanks in adance,

    - Brian

       

  • Brian, did you ever solve this issue?
  • No, not yet. I am currently debugging my program by executing it from RAM.

    I would be happy if someone could help me running it from flash.

    - Brian

  • Brian,

    I came across the same error. I assume this is some trap in the ROM section. As I stepped through my code, I noticed that it occurred when I tried to switch the clock to an external oscillator. I took a stab that perhaps this was because I hadn't initialized the flash with the proper timings. At least for my project, I got this to go away by doing the "ramfuncs" memcpy and calling InitFlash immediately upon entry to main. Previously, I had the InitSysCtrl call as the first thing I did upon entry to main. This solved the error for me. I hope this helps.
  • Gents,

    There is example code in appnote SPRA958 including for F2803x device. It shows proper initialization procedure for running code from flash. Suggest starting with this code. It can be used as a starter project.

    Regards,
    David