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.

Program hung in the PDK library function

Hello all,

I succesfully used the following codes:
    platform_uart_init(); 
    platform_uart_set_baudrate(115200);
    write_uart("\r\n\r\n == Version of the Project == ");
    write_uart(version);
    write_uart("\r\n");
in lot of the programs.
But after revision of one variable's value  the program hung in the function
    platform_uart_init();
When I researched the program execution step by step I saw that program hung within the function
    platform_uart_set_baudrate(115200);

In Disassembly window I found that the program succesfully executed the codes:

             platform_uart_init: 
00837a48: 01BC54F6 STW.D2T2 B3,*B15--[2]
00837a4c: 100FAC12 CALLP.S2 UartInit (PC+32096 = 0x0083f7a0),B3
             $C$RL50:
00837a50: 02610028 MVK.S1 0xffffc200,A4

but during execution of the command:

00837a54: 020000E9 MVKH.S1 0x10000,A4

program hung and the Disassembly window became blank.

Unfortunately I can't send the complete sourse code.

Please answer on the following questions:
- how to find the cause of such code's behavior?
- how to correct this problem?

I used:
Code Composer Studio 5.2.1.00018
mcsdk_2_01_02_06
pdk_C6678_1_1_2_6
Compiler version TIv7.4.7
MDSEVM6678L board

Best regards,
Viktor

  • Check that B15 is within the bounds of the .stack section before, during, and after the STW and the call to UartInit.
    Try making your .stack section significantly larger.
    Is it possible that an interrupt could be occurring sometime within this code sequence? If so, it too could modify the stack.
  • Hello Archaeologist

    thank you for your quick reply.

    >Check that B15 is within the bounds of the .stack section before, during, and after the STW
    > and the call to UartInit.
    >Try making your .stack section significantly larger.


    These is the codes of initial part of the main function:
    --------------------------------------------------------


    main:
    008302d8: 0FF3662A MVK.S2 0xffffe6cc,B31
    008302dc: E0100000 .fphead p, l, W, BU, nobr, nosat, 0000000b
    008302e0: 0F80066A MVKH.S2 0xc0000,B31
    008302e4: 0F3C0FDB MV.L2 B15,B30
    008302e8: 07BC1FD9 || MV.L1X B15,A15
    008302ec: 07BFFCF4 || STW.D2T1 A15,*B15--[B31]
    008302f0: 067821C6 STDW.D2T2 B13:B12,*-B30[1]
    008302f4: 057841C6 STDW.D2T2 B11:B10,*-B30[2]
    008302f8: 01F8A0F6 STW.D2T2 B3,*-B30[5]
    008302fc: 073CC074 STW.D1T1 A14,*-A15[6]
    00830300: 063C8144 STDW.D1T1 A13:A12,*-A15[4]
    00830304: 053CA144 STDW.D1T1 A11:A10,*-A15[5]
    00830308: 0200A35A MVK.L2 0,B4
    0083030c: 051003A2 MVC.S2 B4,TSCL
    00830310: 00000000 NOP
    00830314: 004403E2 MVC.S2 DNUM,B0
    00830318: 21E4A120 [ B0] BNOP.S1 $C$L40 (PC+1936 = 0x00830a90),5
    0083031c: 100EE912 CALLP.S2 platform_uart_init (PC+30536 = 0x00837a48),B3
    $C$RL8:

    platform_uart_init:
    00837a48: 01BC54F6 STW.D2T2 B3,*B15--[2]
    00837a4c: 100FAC12 CALLP.S2 UartInit (PC+32096 = 0x0083f7a0),B3
    $C$RL50:
    00837a50: 02610028 MVK.S1 0xffffc200,A4
    00837a54: 020000E9 MVKH.S1 0x10000,A4
    00837a58: FD5B || CALLP.S2 platform_uart_set_baudrate (PC-44 = 0x00837a14),B3
    $C$RL51:
    00837a5a: 0626 MVK.L1 0,A4
    00837a5c: E8408000 .fphead n, l, W, BU, br, nosat, 1000010b
    00837a60: 71F7 LDW.D2T2 *++B15[2],B3
    00837a62: 6C6E NOP 4
    00837a64: 008CA362 BNOP.S2 B3,5


    Content of the B15:
    -------------------

    B15=0x0C2FFFF8
    before the command
    008302d8: 0FF3662A MVK.S2 0xffffe6cc,B31

    B15=0x0BFC64C8
    after command
    008302e4: 0F3C0FDB MV.L2 B15,B30

    B15=0x0BFC64C0
    after command
    00837a48: 01BC54F6 STW.D2T2 B3,*B15--[2]

    during execution of the command
    00837a54: 020000E9 MVKH.S1 0x10000,A4
    program hung.
    After that
    B15=0x0BFC64C0
    and Disassembly window became blank.

    After I increased stack up to 4M (full size of the MSM)
    all worked properly.

    But after I additionally incresed the the value of the constant, that icreased size of the static arrays
    I watched the same hang.

    So, all worked as you wrote.

    Could you additionally answer on the questions:
    Why did the program work until command
    00837a54: 020000E9 MVKH.S1 0x10000,A4
    when B15 was already irrelevant (0x0BFC64C8) ?
    what does mean blank Disassembly window?


    >Is it possible that an interrupt could be occurring sometime within this code sequence?
    > If so, it too could modify the stack.
    I did not use the interrupts.
    Could you suggest: how to disable the interrupts to reliably
    avoid of any interrupt's occurring during the programm execution?

    Thank you.

    Best regards,

    Viktor.

  • You show various values of the SP (B15).  But I can't tell whether this means the stack has overflowed.  Look in the map file and find the memory range allocated for the .stack section.  The map file is usually located in the Debug directory of the project, with the name project_name.map.  Determine whether B15 is always within .stack.

    Viktor Grytsenko said:
    during execution of the command
    00837a54: 020000E9 MVKH.S1 0x10000,A4
    program hung.
    After that
    B15=0x0BFC64C0
    and Disassembly window became blank.

    When CCS is stopped at breakpoint, the instruction indicated by the arrow is about to enter Decode phase.  When you step over that instruction, it only advances through Decode phase, and does not complete execution.  Thus, the instruction you show is not the interesting one.  The interesting instruction is whatever is about to complete execution.  That instruction will be about 5 cycles or so earlier.  

    Viktor Grytsenko said:
    But after I additionally incresed the the value of the constant, that icreased size of the static arrays
    I watched the same hang.

    I'm not sure what constant you mean.  I presume this means more stack is required than before.

    Viktor Grytsenko said:
    Could you suggest: how to disable the interrupts to reliably
    avoid of any interrupt's occurring during the programm execution?

    That's a system detail we compiler experts are not familiar with.

    Thanks and regards,

    -George

  • Thank you,

    Best regards,

    Viktor