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.

CCS/TMS320C6455: Program Counter (PC) getting out of sync, jumps to a wrong address

Part Number: TMS320C6455


Tool/software: Code Composer Studio

Hi,

I am having a problem in which the program counter jumps to an address of a global variable instead to the address of the next function, Did anyone ran into this issue before?

This is what I get before 

That suits to that function, which makes sene

This is what I get when moving to the next line:

 

which suits to a global array

What can be the problem? Please help!

Thanks,

Keren

  • Without more details about the code and debug environment it is really difficult to tell what could be happening or what the problem could be.  
    If you open the disassembly view in CCS, you can observe the assembly instructions as you step through the code. That might give you more insight into which instruction(s) is jumping to the incorrect address, and perhaps help you narrow down the issue further from there.

  • Hi,

    Thank you for your answer.

    Some other details:

    I saved some screenshots of the program flow, including the memory data of the stack. I wanted to check whether the function return address is ran over, and it seems that it really is ran over. However, I don't understand the reason.

    The code section I am checking includes send_album_window --> PrepareWinHeader --> get_length functions flow.

    At first, getting inside send_album_window and saving the return address from that function:

    Then getting inside PrepareWinHeader and saving the return address from that function (we can see that the return address from send_album_window stays the same, located at the same memory address):

    Now we are just before getting inside get_length. That screenshot occurs a step before the running over:

    When getting out of the if-else inside PrepareWinHeader, can see that the address for returning from PrepareWinHeader is ran over(the return address from send_album_window stays the same, located at the same memory address):

    After that, moving step by step (F10), I finish the function and move right to the disassembly window (now the return address from send_album_window is changed too):

    After that I get an exception:

    I am adding the code:

     

    void send_album_window(int alb_dsp_n)
    {
    int an,theOffset, queHdrLength;
    int numOfPixels, dimX, dimY;
    int* alb_buf;
    int noDebugInfo,i;
    short nCam;

    dimX = dimY = 100;
    numOfPixels = dimX * dimY;

    // loop on number of windows
    for (an = 0; an < alb_dsp_n; an++)
    {
    nCam = album_window[an].nCam - 1;

    if ( (nCam == SelvageCameras.CameraForSearchingLeftSelvage) || (TwoLinesOneXInterface && (nCam == SelvageCameras.CameraForCopyingLeftSelvage)) )
    {
    //B U G I N F I R S T C A M E R A S H O U L D B E F I X E D !!!!
    alb_y0 = album_window[an].nPositionY[1];
    alb_y0 |= (album_window[an].nPositionY[0] << 16);
    if ((album_window[an].nPositionX > 1200 ) || (alb_y0 > 980))
    {
    if(!(album_window[an].nDefectFlags & 0x80))
    {
    continue;
    }
    }
    }

    alb_buf = (int*)MsgDebugWindow;
    alb_x0 = album_window[an].nPositionX;

    if (alb_x0 > 1240)
    {
    continue;
    }

    /////Omer - debug code for no debug info issue!!!!
    noDebugInfo = 1;
    for (i = 0; i < 32; i++)
    {
    if ( (album_window[an].arrayDefects[i].nFactorL != 0) || (album_window[an].arrayDefects[i].nFactorH != 0) || (album_window[an].arrayDefects[i].nFactorD != 0) )
    {
    noDebugInfo = 0;
    break;
    }
    }

    if (noDebugInfo)
    {
    ERR_SendMsg(ERR_CODE_NO_DEBUG_INFO,ERR_FORMAT_DEC,nCam+1,an,1,alb_dsp_n);
    }

    alb_y0 = album_window[an].nPositionY[1];
    alb_y0 |= (album_window[an].nPositionY[0] << 16);
    alb_sze = album_window[an].nWindowSize;

    queHdrLength = sizeof(strMessAlbomWindow) + numOfPixels + sizeof(strMessAWPicture);
    QueSetMsgHdr(alb_buf, 1, 1, queHdrLength);
    alb_buf += (sizeof(QUE_MsgHdr) >> 2);

    PrepareWinHeader(an, alb_buf, nCam);
    alb_buf += (sizeof(strMessAlbomWindow) >> 2);

    SetHdrPicture(alb_buf, dimX, dimY);
    alb_buf += (sizeof(strMessAWPicture) >> 2);

    SendWindow(an,alb_buf,alb_sze,theOffset);
    ImageNr++;
    }
    }

    ///////////////////////////////////////////////////////////////////////////////////////

    void PrepareWinHeader(int an, int* alb_buf, short nCam)
    {
    int lmw;
    int alb_x0_mm,alb_y_in_frame;

    // clear dfi number from the field in order to not disturb PC:
    album_window[an].nWindowNumber &= 0xffff;
    alb_x0_mm = transfer_to_mm(alb_x0, nCam);
    if (alb_x0_mm < 0)
    {
    alb_x0_mm = 0;
    }

    album_window[an].nPositionX = alb_x0_mm + CamLeftMM[album_window[an].nDsp] - CamLeftMM[SelvageCameras.CameraForSearchingLeftSelvage];
    if (style_par->m_sDebug_0.nSpare1 == 0x5)
    {
    ERR_SendMsg(ERR_CODE_X_POSITION_DATA,ERR_FORMAT_DEC,CamLeftMM[SelvageCameras.CameraForSearchingLeftSelvage],nCam+1,an,alb_x0);
    ERR_SendMsg(ERR_CODE_X_POSITION_DATA,ERR_FORMAT_DEC,alb_x0_mm,CamLeftMM[album_window[an].nDsp],album_window[an].nDsp,album_window[an].nPositionX);
    }

    album_window[an].nPositionX -= transfer_to_mm(CamVarArray[SelvageCameras.CameraForSearchingLeftSelvage].aoi_p_left - selv_int_left, nCam);

    if (style_par->m_sDebug_0.nSpare1 == 0x5)
    {
    ERR_SendMsg(ERR_CODE_X_POSITION_DATA,ERR_FORMAT_DEC,transfer_to_mm(CamVarArray[SelvageCameras.CameraForSearchingLeftSelvage].aoi_p_left - selv_int_left, nCam),
    CamVarArray[SelvageCameras.CameraForSearchingLeftSelvage].aoi_p_left,selv_int_left,album_window[an].nPositionX);
    }

    album_window[an].nDsp = 0;

    album_window[an].nStartCCL_Y[0] = xy_res[nCam] >> 4;
    album_window[an].nStartCCL_Y[1] = xy_res[nCam] >> 4;

    alb_sze = album_window[an].nWindowSize;

    // protect coordinates out of frame:
    alb_y_in_frame = dist_from_start((alb_y0 + 32),1, nCam);
    alb_y_in_frame -= 32;

    if (style_par->m_sYRes.nCode != CAM_LM)
    {

    HWI_disable();

    lmw = get_length(start_frm_process + alb_y_in_frame, nCam) + length_meter + loom_def->camDef[nCam].nY - get_length(512, nCam);

    HWI_enable();

    }
    else
    {
    lmw = PlaceDef + loom_def->camDef[nCam].nY;
    }

    album_window[an].nPositionY[0] = lmw >> 16;
    album_window[an].nPositionY[1] = lmw & 0xffff;

    if (style_par->m_sDebug_0.nSpare1 == 0x5)
    {
    ERR_SendMsg(ERR_CODE_Y_POSITION_DATA,ERR_FORMAT_DEC,lmw,PlaceDef,(int)(loom_def->camDef[nCam].nY),(int)nCam);
    }
    /*
    if (zoom_flg == 1)
    {
    album_window[an].nWindowSize <<= 1;
    }
    */
    SettingAlbum_X0_Y0(nCam);

    album_window[an].nPixelX0 = alb_x0 << 2; // Sending X0 position to the PC
    album_window[an].nPixelY0 = alb_y0 & 0x7f; // Sending Y0 position to the PC

    memcpy((unsigned int *)alb_buf,(unsigned int*)&album_window[an],sizeof(strMessAlbomWindow));
    }

    //////////////////////////////////////////

    int get_length(int line_n, short nCam)
    {
    int lines_lsb,lines_msb,tot_lngth;
    int part_a,part_b;
    int line_nn;
    int yy_res;

    if (line_n < 0)
    {
    return 0;
    }
    line_nn = line_n;
    yy_res = (int)xy_res[nCam];
    lines_lsb = line_nn & 0xffff;
    part_a = (lines_lsb * yy_res) >> 14; // 1024: >>10;
    lines_msb = (line_nn >> 16) & 0xffff;
    part_b = (lines_msb * yy_res) <<2 ; // 1024: >>6;
    tot_lngth = part_a + part_b;
    return tot_lngth;
    }

    /////////////////////////

    Any help would be really appreciated!!

    Thanks a lot,

    Keren

  • I think I am having a stack corruption by an Interrupt. I can see that the problem happens right after enabling the hardware interrupts. When I get inside the interrupt, right in the entrance of the interrupt, the memory is over written. Its very difficult to understand what caused the problem, does anyone has a working method how to find the problem?

    Thanks a lot,
    Keren
  • Keren,

    You are using CCS 3.3 which is very old and no longer supported. The compiler tools that came with that version of CCS are also very old so if the issue you are seeing is by any chance due to a compiler bug then there is not much we can do other than recommend that you upgrade to newer tools.

    Having said that, if you think this issue is due to a stack overflow, these pages might help point you in the right direction to help with debugging.

    http://processors.wiki.ti.com/index.php/Stack_and_Heap_size_requirements

    http://processors.wiki.ti.com/index.php/Checking_for_Stack_Overflow