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.

Unexpected value of variable

Other Parts Discussed in Thread: EK-TM4C123GXL

Hello,

I have tiva c series ek-tm4c123gxl and the latest CCS with the a test updates.

I need someones help to figure out what is wrong with my environment. I have an issue but this problem happens not in my own code but in driverlib. For example in method SSIConfigSetExpClk in ssi.c

if ulSSIClk = 16 000 000 and ulBitRate = 8. I this case ulMaxBitRate should equal to 2000000 but when I try to debug the next step after assignment ulMaxBitRate become 0. And program got to infinity loop.

ulMaxBitRate = ulSSIClk / ulBitRate;
ulPreDiv = 0;
do
{
ulPreDiv += 2;
ulSCR = (ulMaxBitRate / ulPreDiv) - 1;
}

What's wrong with my environment in this case? Am I missed something in project settings?

Best regards,

Nikolay

  • Hello Nikolay,

    The driverlib.lib if compiled with the optimization option can create this issue. Please recompile the driverlib with optimization set to 0.

    Regards
    Amit
  • Mykola Kozoriz said:
    I this case ulMaxBitRate should equal to 2000000 but when I try to debug the next step after assignment ulMaxBitRate become 0. And program got to infinity loop.

    Can you clarify:

    1) Which version of the compiler is used.

    2) Where does the program go into the infinity loop?

    i.e. does the SSIConfigSetExpClk() function never exit the while loop shown in the code fragment or does the infinite loop in the faultISR get entered?

  • Mykola Kozoriz said:
    if ulSSIClk = 16 000 000 and ulBitRate = 8

    Do you really want a bit rate of 8Hz, or is that a typo?

    Single stepping the SSIConfigSetExpClk function in TivaWare v2.1.1.71 with ui32SSIClk=16000000 and ui32BitRate=8 shows that the calculated ui32PreDiv is 7784, which is greater than than the maximum value of 254 which can be written to the SSI Clock Prescale (SSICPSR) register. Therefore, a bit rate of 8Hz is not possible.

  • Mykola Kozoriz said:
    I this case ulMaxBitRate should equal to 2000000 but when I try to debug the next step after assignment ulMaxBitRate become 0.

    Using TI ARM compiler v5.2.6 and TivaWare v2.1.1.71 I can't repeat this.

    For Optimization Levels from Off to 3 the ulMaxBitRate variable is shown with the expected value when single stepping.

    For the maximum Optimization Level 4, the ulMaxBitRate variable is not shown in the debugger, when SSIConfigSetExpClk is called with constants for ui32SSIClk and ui32BitRate. In this case the Whole Program Optimizations would have allowed the optimizer to replace the ulMaxBitRate calculation with a constant.

    In all case SSIConfigSetExpClk didn't get stuck in an infinite loop.