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.

Compiler/TMS320F2808: compiled code malfunction

Part Number: TMS320F2808

Tool/software: TI C/C++ Compiler

CCS Version: 10.0.0.00010
Compiler Version: TI v20.2.1.LTS
MCU: TMS320F2808

I use the macro "DELAY_US(100)" to insert a 100us delay in my source code, and this macro is defined in the file "DSP280x_Examples.h" redirecting to an ASM implementation in file "DSP280x_usDelay.asm" with the function name "DSP28x_usDelay". But I noticed that the program jumped to ILLEGAL_ISR() and stopped here after the code DELAY_US(100) being executed. Further debugging revealed that the asm function "DSP28x_usDelay" functions abnormal. The value in ACC register should be decreased by 1 step by step, but this dose not happen. The PC register redirects the program to a meaningless address, and then jumps to the default ILLEGAL_ISR().


Some figures below illustrate the debug information when this case happened. Is there any method could be taken to solve this problem? I'm glad to get any proposal, many thanks!

  • Breakpoint is set at source code "SUB ACC, #1"
  • Without ACC subtraction, the program directly jumps to location 0x00270000

  • And then jumps to ILLEGAL_ISR()

  • If you tried attaching images, they didn't come through. Try again?

    Jumping to the ILLEGAL_ISR() in connection with DELAY_US() most often comes up when you're running the application from flash and have forgotten to do a memcpy to copy "ramfuncs" functions (like DSP28x_usDelay) from flash to RAM. Basically, the application jumps to RAM to execute the code, but the code isn't there and it instead tries to decode an invalid instruction.

    Does that sound like your situation? If you need an example of how to perform the copy and use the ramfuncs symbols from the linker, take a look at the flash example for your device.

    Whitney

  • Hi, Whitney, thank you for your detailed explanation. I did run the program on FLASH, but it seemed the situation was not caused by which mentioned above. I checked the project configurations according to the hint you provided and the following facts ware confirmed:

    • The function was directed to the section "ramfuncs"

    • LOADing and RUNing address were assigned to the section "ramfuncs" in the file "F2808.cmd"

    and in the  .map file I  noticed that the code _DSP28x_usDelay was allocated to the RAM memory.

    Based on the above information, I believe that the function "DSP28x_usDelay" could be addressable at the RUN location. 

    The pictures that were not corrected displayed in last post are listed bellow:

    Figure 1 asm source code

    Figure 2 Related Disassembly

    Figure 3 ACC/PC registers

    Figure 4 Disassembly after Step-Into operation

    Figure 5 ACC/PC registers after Step-Into operation

    Figure 6 Program stops in ILLEGAL_ISR()

    Figure 7 Disassembly of ILLEGAL_ISR()

    Figure 8 ACC/PC registers when program stops in ILLEGAL_ISR()

  • Where are you doing the memcpy to move the code from flash to RAM? I agree that between the .map and .cmd file that  the code is correctly loaded into Flash and expected to execute from 0x8000 in RAM, but what you showed in the disassembly window is not the code that is supposed to be there.

    So either you are missing the memcpy to place the code there or something has overwritten the function.

    Thanks,

    Whitney

  • Thanks for your reminder, Whitney, the problem seems solved.

    I do have the MemCopy function in the program, as following illustrated, but it was misplaced. I moved the codes to the beginning of the program before system initialization and it operated normally.

    Thanks again for your patient instruction.