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.

Problem with moving App from PC to C6455

Hello,

I had the Lattice Implementation of LPC algorithm on my computer. My implementation on computer runs completely fine but when I move it to DSK6455 with some minor changes, it doesn't work. The scenario is like this:

while(read(buffer))

{

    A;

   for(i=0; i<10; i++)

   {

           B;

           C;

   }

   D;

}

where A, B, C, D are blocks of code. I set "software breakpoint" at a code line in block C. The program can reach that line at the first time (i=0). But if I press F5 to continue debugging, it couldn't reach that line again. I did couple tries and observed that:

-If I halt the program, the cursor runs to

;; ======== HWI_Obj HWI_RESET ========
;; defines function for the RESET ISR
;;
;; HWI_Obj HWI_RESET (function, monitor, addr, dataType, operation, client, iUseDispatcher, iArg, IntrMask, iCCBitMask, iLoadTrack)
................

................
[cursor here]  HWI_Obj 1, HWI_RESET, 0, _function, _monitor, _addr, _dataType, _operation, _client, _iUseDispatcher, _iArg, _IntrMask, _iCCBitMask, _iLoadTrack

- If I comment A and B, the program can reach D.

I don't think there is any problem with my code since it runs completely fine on my laptop. I actually use dsk_app example developed for C6455 and add needed functions to it. I doubt there are some issues with the memory. But it still doesn't make sense for me since the maximum memory for variables in my program is around 20KB.

If you need to see my code, let me know, I can upload it here.

Thank you for your help.

Pete.

  • Hi Pete,

    You can attach your code to your forum profile and paste the link here so we can help you understand what is the problem.

  • Try removing A, B, C, D and see if the problem is still there.  That should help diagnose whether the issue is in the framework or in the algorithm. 

  • After the first pass through C do you make it to B again? Are you sure you're not overflowing your stack or something like that?

  • Tim, I guess "overflow" may be the problem. I went to "Build Option" and change my stack to from 30k to 100k but the problem still happens. Other things I have to do to change my stack size?

    Below is my function. Please notice 2 lines that have //////////////////// software breakpoint.   When the program reaches the first software breakpoint, I press F5 and it runs to the second breakpoint. Continue F5, it still can reach 2nd breakpoint (i=2 in this case). F5 again, nothing happens. Then I halt the program, the cursor runs to

    HWI_Obj 1, HWI_RESET, 0, _function, _monitor, _addr, _dataType, _operation, _client, _iUseDispatcher, _iArg, _IntrMask, _iCCBitMask, _iLoadTrack

     

    #define BUFFSIZE 2880

    #define N 1440

    #define M 10

    //Code from dsk_app

    .......

    //My function

    void analyze(Int16 *inbuf)//analysis filter
    {
        Int16 i, j, n;
        Int16 cur_frame=0;
        Int16 cur_sample=0;
        double s[N], r[M+1], K[M+1];
        double a[M+1], aold[M], error, q, eps[M+1], bet[M+1], betold[M+1];

        // Set initial values to zero
        for ( i = 0; i <= M; i++ ) eps[i] = bet[i] = betold[i] = 0.0;
       
        // Beginning of speech anlysis
        cur_sample = cur_frame*N;
        while ( cur_sample < BUFFSIZE )
        {
            for(i=0; i<N; i++)
                s[i] = (double)inbuf[cur_sample+i]/32768.0;
       
            // Calculation of Autocorrelations
            for (i = 0; i <= M; i++)
            {
                r[i] = 0.0;
                for ( n = 0; n < ( N - i ); n++ )
                {
                    r[i] = r[i] + s[n] * s[n+i];
                }
            }

            // Calculation of the reflection coefficients
            error = r[0];
            for ( i = 1; i <= M; i++ )
            {
                for ( j = 1; j < i; j++ )
                    aold[j] = a[j];
                q = r[i];
                for ( j = 1; j < i; j++ )
                    q = q - a[j] * r[i-j];
                K[i] = q / error;
                error = error * ( 1.0 - K[i] * K[i] );
                a[i] = K[i];
                for ( j = 1; j < i; j++ )
                    a[j] = aold[j] - K[i] * aold[i-j];
                rc[cur_frame*M+i-1]=K[i];
            }

            // Implementation of the lattice analysis filter
            for ( n = 0; n < N; n++ )
            {
                eps[0] = bet[0] = s[n];/////////////////////////////////////////////////////////////////////////// first software breakpoint
                for ( i = 1; i <= M; i++ )
                {
                    eps[i] = eps[i-1] - K[i] * betold[i-1];
                    bet[i] = betold[i-1] - K[i] * eps[i-1];//////////////////////////////////////////////////////////////////////////////////// second software breakpoint
                }
                for ( i = 0; i < M; i++ ) betold[i] = bet[i];
                err[cur_frame*N + n]=eps[M];
            }
           
            //Update current frame and current sample value
            cur_frame++;
            cur_sample = cur_frame*N;
        }
    }

    Please let me know if you need the complete source file (though it just the dsk_app + my function).

    Thanks,

    Pete.

  • For best debugging and early check-out of a program, be sure to use the default Debug configuration so that all debugging features are available and no optimization is being used. See if the program behaves any differently this way.

    Put a breakpoint at the HWI_RESET location where the program is ending up when it fails. This way you will halt the first time you get there in case you are running in a loop that keeps sending you there on an abort of some kind.

    With breakpoints at A and B and C and D, it sounds like you would hit A then B then C, but then what? Like Tim was asking, there is a lot more to be uncovered. Most likely, we will be able to help with the "how to debug" rather than the cause, until you get it down to the exact operation that is leading to the failure.

    If you are lucky (and let's plan on that), then this is very reproducible and you can know the last of the ABCD breakpoints that you hit before the failure. Then run to that last successful point and add more breakpoints or just source-single-step until you get to something bad happening.

  • You didn't mention from what context you are making these function calls.  If calling from main or a HWI/SWI then you would need to increase the system stack.  If calling from a task you need to increase the stack of that task.  If you want to monitor the stack with emulation logic more info can be found here:

    http://wiki.davincidsp.com/index.php?title=Checking_for_Stack_Overflow_using_Unified_Breakpoint_Manager

    A lot of tips identifying the root cause of this sort of scenario are given here:

    http://wiki.davincidsp.com/index.php?title=DSP_BIOS_Debugging_Tips

    Brad