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 in running program using flash

Other Parts Discussed in Thread: CONTROLSUITE

Hi all,

I encountered a problem which is unreasonable for me, and I hope anybody probably know this can give me a hint. In short, using flash .cmd file causes the interrupt I set failed to be triggered(which woks fine if using RAM .cmd). Below is the details:

I am using 28033 as my processor. And the main source file contains three parts: CPU timer interrupt ISR, SPIFIFO interrupt ISR, and infinite for loop in main function. CPU timer interrupt will be triggered at certain time interval, and this CPU timer interrupt is used to start data transmission using SPI. Then CPU timer interrupt ends and wait for the SPIFIFO interrupt. After a while when SPI data transmission complete(I set the depth of SPIFIRO RX to be 1), SPIFIFO interrupt will be triggered and do some calculation. SPIFIFO interrupt will always ends on time to get CPU ready to receive next CPU timer interrupt. In my previous program, the .cmd file is RAM type, and it works fine. After I change my .cmd file to flash which comes from ControlSuite flash .cmd file example without any modification, I made some change in my program. That is to declare:

#pragma CODE_SECTION(InitFlash, "ramfuncs");------before my main function

memcpy((Uint16 *)&RamfuncsRunStart,(Uint16 *)&RamfuncsLoadStart, (unsigned long)&RamfuncsLoadSize);
InitFlash();----------------Copy InitFlash function to ram and run it

No error is shown while building this project, and the result when debugging this program was that CPU timer interrupt and SPIFIFO interrupt was successfully triggered once. After the SPIFIFO interrupt was finished, the next CPU timer was interrupt never triggered again. And of course same for the SPIFIFO interrupt afterwards.

Since I didn't make any other modification to my program but the two mentioned above, is there any reason which causes my CPU timer interrupt and SPIFIFO interrupt just triggered once?

Any help is appreciated!

Hezi

  • Hi Hezi,

    Did you refer the cpu_timer example code that is available in controlSuite?

    Regards,
    Gautam
  • Yes Gautam, there's nothing wrong with my cpu timer setting or interrupt itself. I've know more about this problem, the cpu timer interrupt is working fine(I observe the PIEACK bit). The problem is in SPI interrupt. In SPI interrupt isr, I cleared the int flag and overflow flag using statements shown below:
    SpiaRegs.SPIFFRX.bit.RXFFOVFCLR=1; // Clear Overflow flag
    SpiaRegs.SPIFFRX.bit.RXFFINTCLR=1; // Clear Interrupt flag
    It works fine with RAM cmd, but those two bits are not cleared with FLASH cmd. Therefore, after run once the int flag and overflow flag are set high but never cleared, SPI is not able to generate the interrupt again. Since I called InitFlash() function in my main function, the InitFlash() function is also shown below:
    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");
    }

    Could this happen because of the flash register setting?

    Thank,
    Hezi
  • Hezi, you mentioned about clearing the flag but what about the PIE acknowledgement ?

    PieCtrlRegs.PIEACK.all|=0x20;       // Issue PIE ack

    Simply check this sample code: Example_2803xSpi_FFDLB_int.c

    and try using this cmd file for flash: F28033.rar

    Regards,

    Gautam

  • Hi Gautam,

    Thanks for your reply! Yes I have statement of PIE ACK in my subroutine, and it works fine with RAM cmd. And the 28033 cmd file you gave me is exactly the FLASH cmd I am using now in my project. I first think that maybe the problem is caused because that program run slower in FLASH and my SPIFIFO interrupt can not end before my next CPU interrupt. And so my SPI interrupt is masked by the CPU timer interrupt. To verify this I delete all statement except the one to clear INT FLAG and OVERRUN FLAG, and this PIE ACK. Still I can't make my SPI interrupt execute and reset.

    Do you have any idea how this problem could be caused because of the change of position of my program? Or is it relevant to the setting of my Flash Regs? Could it be possible that the wait mode setting disabled me from doing this?

    Thanks!

    Hezi 

  • Hezi,

    Can you try this and report back?

    Declare your ISR functions to be run from RAM. Do this with the #pragma CODE_SECTION(&<isr_name>, "ramfuncs") command. When you call the memcpy function, your ISRs will be running from RAM, and not be slowed down by the Flash waitstates. I believe this might help your problem.

    If this does not work. Try removing the CPUtimer functionality and verify that the SPI functionality works. Then do the opposite, where you disable the SPI function and verify if either one is experiencing an issue.

    Please let me know what you find!

    -Mark