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.

Code debugging problem of TMS570LS20216SPGE using CCS 4

Other Parts Discussed in Thread: TMS570LS20216

Hi

I'm implementing a big algorithm into TMS570LS20216 using CCS4 at the moment. After some parts, the debugger will jump to sys_intvecs.asm stop at b #-8 of _data. There is no errors in the part where the debugger jumps, since it is only about memory allocation. Even if i delete the part where the debugger jumps, it will jump again in the next part. Can anyone tell me what is the problem i'm facing? Is it related to the momery of the chip? How can i solve this problem?

Thanks in advance

Rui

  • Rui,

    It seems that you have a data abort. There are two possible causes for data abort: (1) Flash or RAM ECC error and (2) CPU accesses some invalid memory region. You can debug this issue by first checking the LR register. It has the address of the code which causes the abort. Then you can look at the data access instructions at and before this address and check the value of the registers used for address. You may also need to check the stack pointer to see if you allocated enough space for stack.

    Please let me what you find.

    Thanks and regards,

    Zhaohong

  • Thanks for your reply Zhaohong,

    I checked LR register from Core Registers showing address of abortion. I dont find any errors from the instruction at the address. Like i mentioned, when i delete some codes, they will jump at new line, I have found that the SP resets after the jump. And if i change some memory allocation, e.g., A[0] = B[1] to A[0] = 0, which less memory will be used, the debugger can go a little bit further then jump again, from which i am wondering that perhaps the problem is due to the memory size of the controller.

    I'm decreasing the size of my code at the moment to see what will happen.

    Rui

  • I found more things actually. SP will become 0x08001400 when the abortion happens. The original value is 0x08001100. The abortion always happens inside my own function, the SP will remain 0x080010D8 before goes into the function then becomes 0x07FFDCD0 at the first line of my function. Does anyone know what has happened here? The drop of the SP address?

  • Rui,

    You may want to disable Flash and RAM ECC for the moment. You can check the link command file to see if the memory section definitions match the spec. Many people like to use dynamic memory allocation. If you use it, make sure that there are no issues.

    Thanks and regards,

    Zhaohong

  • Hi Zhaohong,

    Can you tell me how to disable Flash and RAM ECC? Besides, which spec are u refering to match the memory definitions?

    I generate all the codes using HalcodeGen. I tried to change the user stack length to a bigger value (>0x1000), the code will not run at all.

    The sys_link.cmd is like this:

    /*----------------------------------------------------------------------------*/

    /* sys_link.cmd */

    /* */

    /* (c) Texas Instruments 2009, All rights reserved. */

    /* */

    /* USER CODE BEGIN (0) */

    /* USER CODE END */

     

    /*----------------------------------------------------------------------------*/

    /* Linker Settings */

    --retain=

    "*(.intvecs)"

    /* USER CODE BEGIN (1) */

    /* USER CODE END */

    /*----------------------------------------------------------------------------*/

    /* Memory Map */

    MEMORY

    {

    VECTORS (X) :

    origin=0x00000000 length=0x00000020

    FLASH0 (RX) :

    origin=0x00000020 length=0x0007FFE0

    FLASH1 (RX) :

    origin=0x00080000 length=0x00080000

    FLASH2 (RX) :

    origin=0x00100000 length=0x00080000

    FLASH3 (RX) :

    origin=0x00180000 length=0x00080000

    STACKS (RW) :

    origin=0x08000000 length=0x00001300

    RAM (RW) :

    origin=0x08001300 length=0x00026D00

    /* USER CODE BEGIN (2) */

    /* USER CODE END */

    }

    /* USER CODE BEGIN (3) */

    /* USER CODE END */

     

    /*----------------------------------------------------------------------------*/

    /* Section Configuration */

    SECTIONS

    {

    .intvecs : {} > VECTORS

    .text : {} > FLASH0 | FLASH1 | FLASH2 | FLASH3

    .const : {} > FLASH0 | FLASH1 | FLASH2 | FLASH3

    .cinit : {} > FLASH0 | FLASH1 | FLASH2 | FLASH3

    .pinit : {} > FLASH0 | FLASH1 | FLASH2 | FLASH3

    .bss : {} > RAM

    .data : {} > RAM

    /* USER CODE BEGIN (4) */

    .sysmem : {} > RAM

    /* USER CODE END */

    }

    /* USER CODE BEGIN (5) */

    /* USER CODE END */

     

    /*----------------------------------------------------------------------------*/

    /* Misc */

    /* USER CODE BEGIN (6) */

    /* USER CODE END */ 

    /*----------------------------------------------------------------------------*/


     

  • Rui,

    You link command file seems to be fine. I think that you may have a stack overflow problem. I would suggest the following.

    (1) Increase stack size from 0x1300 to 0x3000.

    (2) Check the local variables/arrays defined in your function. Those variables are save to stack. You need to make sure that they do not go beyond the space you allocated.

    (3) Debug the the issue from the disassembly window. You said that the stack pointer becomes incorrect at the first line of your function. I guess that you mean by c-code. If you step through the calling sequence of this function in disassembly window, CPU will set up a few registers (including the stack pointer) before branching to the address of the function.

    The Flash and RAM ECC is disabled by default.

    Please let me know about your progress.

    Thanks and regards,

    Zhaohong

  • Thanks again for your reply Zhaohong, however, there is still some problems.

    Firstly, i found during the procedure from outside the function to inside the function in the disassembly window, at one step, R13 (register for SP) = R13 - 13320, which makes the stack pointer address lower than stack base address (0x08000000). I assume this step is to allocate the momery for the function.

    I changed sys_link.cmd file like this

    STACKS (RW) :origin=0x08000000 length=0x00003300

    RAM (RW) :origin=0x08003300 length=0x00024D00

    and change sys_core.asm like this

    user: .word 0x08000000+0x00003000

    svc: .word 0x08000000+0x00003000+0x00000100

    fiq: .word 0x08000000+0x00003000+0x00000100+0x00000100

    irq: .word 0x08000000+0x00003000+0x00000100+0x00000100+0x00000100

    abort:  .word 0x08000000+0x00003000+0x00000100+0x00000100+0x00000100+0x00000100

    undef: .word 0x08000000+0x00003000+0x00000100+0x00000100+0x00000100+0x00000100+0x00000100

    I found that R13 minues a bigger value. The  stack address is still smaller than base address  0x08000000. 

  • Rui,

    I believe that you defined too many local variable or array inside your function. At runtime, CPU tries to allocate space inside the stack for them.I also assume that you do not have any interrupt running.

    Thanks and regards,

    Zhaohong

  • Hi Zhaohong,

    I changed some of my code to save memory. Now 0x2000 for the stack is ok and the code can run now. However, the current is a little bit too large (0.22A). I am using 6M ocsillator and pll is 59,14M. If i change the pll to 100, the current will jump to 0.3A. I only enabled RTI and SCI driver in HalcodeGen. Is there any way to lower the current?

    Thanks

    Rui

  • Rui,

    I think that the current consumption you observed is normal. They are within the maximum limit in the data sheet.

    Thanks and regards,

    Zhaohong

  • I see. I will continue to optimize my code. Thanks a lot for your support Zhaohong