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/TMS320F28377D: A question about 28377D data transmission

Part Number: TMS320F28377D

Tool/software: Code Composer Studio

Hi.

Question1: I defined the variable uint16_t ui16Status in the function and assigned the initial value ui16Status = 0.In calling a function as a parameter,

Find that the value was assigned, but the value did not change?

The problem is that the address of ui16Status is 0x00000418, *pui16PortStatus assigns an address 0x00000001 instead of 0x00000418???How to solve?

Thank you for your reply.

  • Hi,

    I have found similar issue when the function prototype was not included in the c file. Can you check if the function prototype is declared in the file that calls this function, or the header file that declares the function prototype is included in the file that calls this function?

    Regards,
    Veena
  • Hi,

    the function prototype is declared in the file that calls this function, As you can see, As shown in the figure below:

  • Hi,

    I can get the value of pui16PortChange, why ?
  • Hi,

    I am forwarding this thread to the compiler team

    Regards,
    Veena
  • Hi,

    Thanks, waiting for your reply online.
  • For the source file usbhhub.c, please follow the directions in the article How to Submit a Compiler Test Case.  That will allow me to generate the assembly code for the problem call.  I think that will allow me to explain what happened, or at least ask better questions.

    koko wilton said:
    the function prototype is declared in the file that calls this function, As you can see, As shown in the figure below:

    That may not be enough.  For it to work as you intend, these lines must appear before any call to the function.  Is that the case?  

    A general tip ... If you build with the option --diag_warning=225, the compiler issues a warning diagnostic any time you call a function that has no prototype visible.

    Thanks and regards,

    -George

    1. Preprocessed source fileusbhhub.pp.txt
    2. Compiler Version
    3. Compiler Options Used
  • Thank you. I look forward to your reply!
  • Thanks for sending in the test case.  I carefully inspected the compiler generated assembly code.  I cannot find anything wrong.

    When you took that screen shot with the bad values for the pointer variable pui16PortStatus, I can't tell where you were in the function HubGetPortStatus.  That pointer gets passed to the function in the register XAR5.  A few instructions into the function, it is copied from XAR5 to a location on the stack.  CCS expects it to be on the stack.  It is possible you took the screen shot before the copy to the stack occurs.  Does that make sense?  If you get several instructions into the function, are things correct then?

    Thanks and regards,

    -George

  • Thank for your answer George.

    "It is possible you took the screen shot before the copy to the stack occurs. "

    I hit the breakpoint before I looked at this value, so When I stopped at the breakpoint, I took a screenshot.

  • Unfortunately, I cannot tell where the breakpoint is.  Is it at the very start of the function?  If so, that's too early.  It needs to be after the instruction which copies the pointer pui16PortStatus from XAR5 to its location on the stack.

    Thanks and regards,

    -George

  • Please let me know where the breakpoint is.

    Thanks and regards,

    -George

  • Since it has been a while, I presume you have resolved the problem.  I'd appreciate hearing how you resolved it.

    Thanks and regards,

    -George

  • In reply to George Mock:

    Thank for your answer George.
    My problem is still unsolved.I'm sure it's copied.At breakpoint,This value is not copied to the correct location.I don't know how to explain it.Stack may be overflow,so An addressing error occurred,I can't get the right value.
  • I apologize for the delay.

    koko wilton said:
    The problem is that the address of ui16Status is 0x00000418, *pui16PortStatus assigns an address 0x00000001 instead of 0x00000418???

    Set a breakpoint at the very first instruction, not C statement, in the function HubGetPortStatus.  The argument &ui16Status is passed in the register XAR5.  Inspect the contents of XAR5.  It should be the address of ui16Status, or 0x418.  Is that the case?  If it is, then I have to suspect the problem is in how CCS displays things, and not the code generated by the compiler.

    Thanks and regards,

    -George

  • Please reply to the questions I ask in the last post.

    Thanks and regards,

    -George

  • Since it has been a while, I presume you have resolved the problem. I'd appreciate hearing how you resolved it.

    Thanks and regards,

    -George

  • I apologize for the delay.
    It should be the address of ui16Status, or 0x418. Is that the case? If it is, then I have to suspect the problem is in how CCS displays things, and not the code generated by the compiler.

    I'm sure that the address of pui16PortStatus shoule be 0x418, but not now.(it is 0x00000001)
    I think this is the question point, so I don't understand how to solve it.
    My solution : Create a global variable to replace it(pui16PortStatus ).

    If you have any other good ideas, please let me know in time. Thank you George.
  • Please reply to the questions I ask in the post dated Feb 22 2019.  I need to know what is in the register XAR5 at the very start of the function HubGetPortStatus.

    Thanks and regards,

    -George

  • Hi George:

     The first picture is as follows:

    • Set a breakpoint before the function HubGetPortStatus. 

     The second picture is as follows:

    • When you step to line 425.
    • Set a breakpoint at the very first instruction, not C statement, in the function HubGetPortStatus.  The argument &ui16Status is passed in the register XAR5.

     

    The third picture is as follows:

    • When you step to line 433. 

     

    The fourth picture is as follows:

    • When you step to line 459.


    The fifth picture is as follows:

    • When you step to line 469.
    • Set a breakpoint After parameter assignment,in the function HubGetPortStatus. 

     

    Function code:

     

     

    Thank you George

    Thank you for your patience.

     

  • This is the program state as of the third picture.  The pointer pui16PortStatus resides at memory location 0x430.  It contains the value 0x418.  Memory location 0x418 contains the value 0.  All of this is correct.

    Sometime between the third picture and the fourth picture things go bad. The memory location 0x430 no longer contains the value 0x418.  It contains the value 1 instead.  It goes downhill from there. 

    I cannot tell what causes the memory location 0x430 to be overwritten with the value 1.  You have to use your debug skills to find the moment where that occurs.  Maybe it happens during execution of the function USBHCDControlTransfer?

    Thanks and regards,

    -George

  • Did you discover why the memory location 0x430 is overwritten with the value 1?

    Thanks and regards,

    -George

  • I can't find the cause of the mistake.

    I guess the CCS v8 compiler problem for this reason.

    Would you give me some advices on the question, please?



    Thanks and regards
  • You could try setting a hardware watchpoint on that address.  If you go to the breakpoints view (looks like it is in the same group of views as your variables view) you can try to set a watchpoint.  A watchpoint is essentially a data breakpoint.  You can set one on an address and have have it halt when that address is accessed.  Depending on the device it will even let you control if the halt is on an access, read or write.  And on some devices you can even specify for it to halt with a write with a specific value.

    If you go to the breakpoints view and click on the little arrow beside the add breakpoint button it will then show you the types of breakpoints supported.  You want a watchpoint.

    Regards,

    John