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 repeats

Part Number: TMS320F28386S

In the program below I set a breakpoint on first executable line. If I hit continue it completes the program and comes back to the breakpoint. The same happens repeatedly. The debugger should stop but it does not.

//main.c

#include "driverlib.h"
#include "device.h"

//
// Main
//
uint32_t main(void)
{
    Device_init();
    Device_initGPIO();

    Interrupt_initModule();
    Interrupt_initVectorTable();

    //
    // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
    //
    EINT;
    ERTM;

    return(0);
}

  • Hi John,

    If you are able to step through the program, does it ever reach the f2838x_codestartbranch_cpu1.asm file?After it returns from this loop a cleanup process should begin.

    Thanks,

    Charles

  • Yes it goes there. When it returns from my program it executes

        BF  _ExitBoot,UNC
          
        MOV SP,#__stack

    ;-----------------------------------------------
    ; Clear the bottom of the stack.  This will endup
    ; in RPC when we are finished
    ;-----------------------------------------------

        MOV  *SP++,#0
        MOV  *SP++,#0

    ;-----------------------------------------------
    ; Load RPC with the entry point as determined
    ; by the boot mode.  This address will be returned
    ; in the ACC register.
    ;-----------------------------------------------

        PUSH ACC
        POP  RPC

    ;-----------------------------------------------
    ; Put registers back in their reset state.
    ;
    ; Clear all the XARn, ACC, XT, and P and DP
    ; registers
    ;
    ; NOTE: Leave the device in C28x operating mode
    ;       (OBJMODE = 1, AMODE = 0)
    ;-----------------------------------------------
        ZAPA
        MOVL  XT,ACC
        MOVZ  AR0,AL
        MOVZ  AR1,AL
        MOVZ  AR2,AL
        MOVZ  AR3,AL
        MOVZ  AR4,AL
        MOVZ  AR5,AL
        MOVZ  AR6,AL
        MOVZ  AR7,AL
        MOVW  DP, #0


    ;------------------------------------------------
    ;   Restore ST0 and ST1.  Note OBJMODE is
    ;   the only bit not restored to its reset state.
    ;   OBJMODE is left set for C28x object operating
    ;   mode.
    ;
    ;  ST0 = 0x0000     ST1 = 0x0A0B
    ;  15:10 OVC = 0    15:13      ARP = 0
    ;   9: 7  PM = 0       12       XF = 0
    ;      6   V = 0       11  M0M1MAP = 1
    ;      5   N = 0       10  reserved
    ;      4   Z = 0        9  OBJMODE = 1
    ;      3   C = 0        8    AMODE = 0
    ;      2  TC = 0        7 IDLESTAT = 0
    ;      1 OVM = 0        6   EALLOW = 0
    ;      0 SXM = 0        5     LOOP = 0
    ;                       4      SPA = 0
    ;                       3     VMAP = 1
    ;                       2    PAGE0 = 0
    ;                       1     DBGM = 1
    ;                       0     INTM = 1
    ;-----------------------------------------------

        MOV  *SP++,#0
        MOV  *SP++,#0x0A0B
        POP  ST1
        POP  ST0

    ;------------------------------------------------
    ;   Jump to the EntryAddr as defined by the
    ;   boot mode selected and continue execution
    ;-----------------------------------------------

        LRETR  <== all the above to here =========================v

    ;eof ----------

    code_start:
        .if WD_DISABLE == 1
            LB wd_disable       ;Branch to watchdog disable code      <== This line then ===v
        .else
            LB _c_int00         ;Branch to start of boot._asm in RTS library
        .endif

        .if WD_DISABLE == 1

        .text

    wd_disable:
        SETC OBJMODE        ;Set OBJMODE for 28x object code  <== Then all lines here
        EALLOW              ;Enable EALLOW protected register access
        MOVZ DP, #7029h>>6  ;Set data page for WDCR register
        MOV @7029h, #0068h  ;Set WDDIS bit in WDCR to disable WD
        EDIS                ;Disable EALLOW protected register access
        ;LB _c_int00         ;Branch to start of boot._asm in RTS library
        LCR main                                                                                         <== Then we are back to here.

  • I find it interesting that some imported projects use

      f2838x_codestartbranch_cpu1.asm

    while others use

      device\f2838x_codestartbranch.asm

  • Compared to another project it seems that a value or offset used by LCR is different. I searched for the assy ref manual for half an hour and never found it so it is hard to speculate if this is some conditional instruction but it seems to control the new destination.

  • At the end of main, would it be possible to put an example_done routine? 

    void Example_Done(void)
    {
    __asm(" ESTOP0");
    }

  • Here is what I have now and I have a breakpoint on line 19.

    It stops there and also on line 11, though there is no break point there. Continue button is still green so pressing it causes the program to stop on line 19 again. Round we go, ad infinitum.

    //main.c
    
    #include "driverlib.h"
    #include "device.h"
    
    //
    // Main
    //
    void Example_Done(void)
    {
    __asm(" ESTOP0");
    }
    
    uint32_t main(void)
    {
        Device_init();
        Device_initGPIO();
    
        Interrupt_initModule();
        Interrupt_initVectorTable();
    
        //
        // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
        //
        EINT;
        ERTM;
        Example_Done();
        return(0);
    }

  • John,

    It looks like your device is getting reset when you run the program. Did you disable watchdog? I'm wondering whether watchdog reset is resetting the device making it to f2838x_codestartbranch_cpu1.asm etc.

    Regards,

    Manoj

  • Hi Manoj,

    Yes, it was disabled int Device_init(), which I have not modified.

    I created a new project and copied my source code into it and now it works. That would not be so bad except that takes a while as it was necessary to copy the includes and linked resources in the project properties.

  • Good to know that you were able to get around the issue. I shall close this ticket for now.

  • Yes,but I wish I knew what caused it. I spent a lot of time debugging something that magically went away when I created a new project.