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.

TIDM-DC-DC-BUCK: Question regarding stepping through program

Part Number: TIDM-DC-DC-BUCK

Hi, when i debug the TIDM-DC-DC-Buck code, after stepped through Tasks State-machine initialization, line 88, it goes back to line 85. Can you help me understand why?

I have modified a little bit on this code, but the original code behaves the same in the portion Tasks State-machine initialization.


  • Hi,

    What do you mean by "Tasks State-machine initialization, line 88, it goes back to line 85" ?


    Do you see C_Task_Ptr pointing A0?



  • Hi, John,

    Reattached the project, which is the original, easy to communicate. if you debug and step through the code, after it execute line 99, it is suppose to go to line 104. But mine goes back to line 96. I don't understand why.


  • Hi,

    How did you check line 104 was not executed? I don't think this is not the case.

    The infinite loop in main and code below line 199 changes the pointer as shown below and repeat this forever.

     &A0 --> ( &A1 --> &A2 --> &A3)  -->  &B0 --> ( &B1 --> &B2 --> &B3) --> &C0 --> ( &C1 --> &C2 --> &C3)

  • Hi, John,

    I am not talking about executing state machine. I am talking about step through the code. I haven't got the for(;;) loop yet.

    Do the following and tell me what you see on your computer:

    1. build the code

    2. click on debug

    3. in debug mode, click 'step over' instead of 'run'

    4. 'step over' one by one until you get to line 99. 

    5. 'step over' one more time, does the little arrow (which representing where the program is now pointing to) go back to 96? (in mine program it is 88 back to 85, since i modified a little bit)

  • Hi,

    Sorry I did not pay attention to step over. The original SW goes to 96 but not sure if this is the actual case.

    The below pointers are not initilized as expected and when you hit step over again, it will be initialized once it go back to line 96. You can check this on expression window by adding the variables. Once they are initialized, it moves to the next line.

    Alpha_State_Ptr = &A0;
    A_Task_Ptr = &A1;
    B_Task_Ptr = &B1;
    C_Task_Ptr = &C1; 

  • Thanks. Do you know why they were not able to initialize the first time?

    I have a problem very similar to this:

    This is a simple function that read an adc input 8 times and write the value to a vector vInSamples_Volts[]. It never able to write vInSamples_Volts[7]. When i step through the line 'vInSamples_Volts[adcSampleIndex] = ADC_readResult', for the first round it is not able to assign value, then it go back to that line again, still not able to assign value. then it starts next round, the rest of the while loop it is able to assign values. 

    The result is attached too. 

    Can you please look into it?


    void readVin(void)
    //set interrupt to number1
    adcSampleIndex = 8;
    do {

    ADC_forceSOC(BUCK_VIN_ADC_MODULE,BUCK_VIN_ADC_SOC_NO);//trigger SOC use software

    while(ADC_getInterruptStatus(BUCK_VIN_ADC_MODULE, ADC_INT_NUMBER1) == 0U);//wait the ADC to be complete

    ADC_clearInterruptStatus(BUCK_VIN_ADC_MODULE, ADC_INT_NUMBER1);//clear the interrupt flag

    vInSamples_Volts[adcSampleIndex] = ADC_readResult(BUCK_VIN_ADCRESULTREGBASE, BUCK_VIN_ADC_SOC_NO);//read adc value
    } while(adcSampleIndex > 0);

  • Hi,

    Instead of writing the ADC result in your loop can you just write adcSampleIndex back to the array?  Since value of 0 is the default ADC Result until there is a first sample, I would like to eliminate if the ADCResult is returning 0, or the index is wrong.



  • Hi, Mathew,

    Good suggestion. Index is correct using your method. Result attached.

    Back to ADC reading. When run to line 860, as shown in the following picture, ADC result register has the correct sample, which make sense. Then the next step line 861, which should assign the ADC value to the variable vInSamples_Volts[7], but it didn't.

  • Thanks for doing this, since you are single stepping I don't think we could have any kind of race condition where the ADC Result is not populated in the result register before you do the read.

    Can you put a breakpoint in ADC_readResult() function and step through that, making sure both the passed ADC base and channel match up to what you expect?

    Based on your previous posts, it looks like the rest of the loop is working, so it seems there may be some initialization issue; but I'm not certain how the ADC_readResult would get a bad value.



  • Hi, Matthew,

    Program stops at breakpoint line 911, when i put cursor at variable resultBase and socNumber, it doesn't show anyvalue. I added two local variables. It doesn't have any value either. also in the expression window, it shows the identifier not found.

  • Shengnan,

    I've asked another C2000 team member who know the drivers a bit better to take a look as well.

    In your watch window can you add the ADC Result Registers(all of them) when you are in the readResult function.  I would like to see at the ADC level if ADCRESULT1 actually has anything in it at the time it is being read.


  • Hi, Matthew,

    Thanks, in the previous reply, i posted this picture, which indicate the ADCRESULT1 register has the correct result in it. 

    Is this what you are asking?

  • Thanks Shengnan, that is what I wanted to see.  Can you set the BP a line earlier on hte ADC_clearINt....line and see if the ADCResult also has a good value at that time?


  • Matthew,

    I am not able to set BP in line 832/834/836. It has puzzling me for a while. Do you know why?

  • It turns out I didn't enable the ADC_INT_No, although it is able to converter, it causes mysterious mistakes. 

  • Shengnan,

    I'm glad we were able to root cause this, and appreciate your patience with TI through the process.  I'm curious, do you know how the code was able to get past the while(ADC_getInterruptStatus(xxxxx) = 0); line?  This should have got caught there forever if the INT wasn't enabled unless it was set from a previous code run?



  • You are right about the issue. I was another mistake regarding interrupt number, after I corrected the interrupt number, it stuck at while().