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.
I am trying to run a function out of RAM (time_1s_tick). I followed all the recommended steps presented in SPRA958K but the microcontroller (28069) goes in the Illegal interrupt when calling the function I placed in RAM.
Please help me.
....................................................................................................................................................................................
Because I didn't get an answer to my question so far I continued to investigate the problem and this is what I found:
My RAM function doesn’t return at the end. It looks that the code continues, I suppose, to run the next code/function in RAM (that is DSP28x_usDelay). When this function (DSP28x_usDelay) tries to return it goes at “0x8036” (No source available for "0x8036") and trigger the Illegal interrupt. So far, I have no explanation for this behavior.
I had similar problems when calling InitAdc function. I found a few topics in this forum about this problem but not a good answer for me. It seems that the InitAdc uses DELAY_US that is a define using the in line DSP28x_usDelay RAM function (it has to be in RAM because it’s used by InitFlash). I solved the problem replacing DELAY_US function with a simple for (for(i=0;i<10000;i++) {}).
Any clue/solution for my problem running a function from RAM is welcomed.
Thanks
Marius,
I suspect something is using a function allocated in ramfuncs before the copy. Can you try putting the copy is the very first thing in your main() and see if that changes the behavior?
-Lori
Lori,
Thanks for your answer.
The main function starts with initializing the flash where the RAM functions are copied from flash to RAM. I read all the documentation a few times and I still cannot find the problem. It is very strange because using the debugger I found that my RAM function doesn’t return and continues with DSP28x_usDelay, also in RAM. When DSP28x_usDelay tries to return (to a not available address because it wasn’t called) the Illegal interrupt is triggered.
Marius Raducanu said:The main function starts with initializing the flash
InitFlash() is part of the ramfuncs. Make sure the copy is before the init of the flash.
Marius Raducanu said:my RAM function doesn’t return
Double check the .map file and make sure the function is truly allocated to RAM.
It really sounds like the copy isn't happening - if you examine the disassembly does it look like a legitimate function? or a bunch of random instructions?
-Lori
Lori,
It works!
I never debugged the part of the program with copying RAM function and initialization of flash because I implicitly supposed that it works because I was able to run my program from flash. Also, there is the note above this section: “// Note that the variable FLASH is defined by the compiler with -d FLASH”.
It looks that was misleading because FLASH is not defined by the compiler (although I use F28069.cmd). After I defined: #define FLASH 1, everything works now.
Questions: Why FLASH wasn’t defined by compiler? Is something that I have to do for this?
Marius Raducanu said:Also, there is the note above this section: “// Note that the variable FLASH is defined by the compiler with -d FLASH”.
It looks that was misleading because FLASH is not defined by the compiler (although I use F28069.cmd). After I defined: #define FLASH 1, everything works now.
Marius,
I agree the wording of the comment is a little confusing. It means you can define it with the compiler by using the -d switch. In the project properties there is a "predefined symbols" option which will add -d <symbol> that you specify. In our flash projects we define the symbol in this manner. Using #define works as well.
Cheers
Lori
The idea of running time critical functions in RAM is so important to execution speed and battery life, it should be worth an app note or even a whitepaper, i would think.
Are there any examples for c28335 delfino or the like.
Thanks
<N/M>
Norman Mainwaring said:The idea of running time critical functions in RAM is so important to execution speed and battery life, it should be worth an app note or even a whitepaper, i would think.
Are there any examples for c28335 delfino or the like.
Thanks
<N/M>
Hi Norman,
A few ideas:
C:\ti\controlSUITE\device_support\f2833x\v133\DSP2833x_examples_ccsv4\flash_f28335
Let me know if that helps.
Cheers
Lori
It could still be related to DELAY_US. I put the memcpy immediately after (or as near as possible) InitSysCtrl() call and before InitPll() and InitAdc().
One minor change to the memcopy code (to accomodate changes to the code):
if (RamfuncsLoadSize != 0)
{
memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (Uint32)&RamfuncsLoadSize);
}