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.

TMS320F280049: F280049 Stack flag/register

Part Number: TMS320F280049
Other Parts Discussed in Thread: C2000WARE

Hi Champion,

Do we have a flag or regiseter in F280049 can check whether stack overflow?

Thanks!

BR

Joe

  • Add one more information, my customer want to code run with a safe protection when stach overflow, do you have any suggestion about it?
  • Hi Joe,

    Embedded Real-Time Analysis and Diagnostics (ERAD) is the new debug module available on the F28004x that consists of the Enhanced Bus Comparator (EBC) units which can monitor accesses to a specified address range, in this case, addresses past the stack.

    Here's the C2000Ware Example and JavaScript file:
    C:\ti\c2000\C2000Ware_1_00_04_00\driverlib\f28004x\examples\erad\stack_overflow

    The file stack_overflow.js file configures ERAD registers and should be run in the CCS scripting console. ERAD registers can also be configured in the customer's application code. While there aren't examples where ERAD is configured in the application code now, the ERAD register header file is available in the Driverlib and bit-field register header directories.

    ERAD is also documented in the TRM and here's a training video:
    training.ti.com/embedded-real-time-analysis-diagnostics-erad-c2000-devices

    The other option is to configure a hardware watchpoint with the C28x Analysis Block (documented here www.ti.com/.../spra820.pdf). This is the only method for devices other than F28004x as ERAD is not available on them. This has the limitation that when the application is run in Flash configuration, setting breakpoints in the code will interfere with the analysis unit's attempt to set this watchpoint and thus not provide the stack monitoring functionality. Other than that, this approach will be a similar functionality as using the ERAD.

    Regards,
    Elizabeth
  • Hi Elizabeth,
    is there a way to use ERAD for stack overflow detection in standalone mode (without debugger connected), too?
    We are actually using the hardware watchpoint method, but this is not nice when switching from standalone mode to debugging mode because of the breakpoint limitation.

    Regards,
    Stephan
  • Here is a good document on describing stack overflow detection.
    www.ti.com/.../spra820.pdf

    Hope this helps.
  • As explained above: We are already using this method.
    I am interested in the ERAD method and if/how it works in standalone mode.
  • Hi Elizabeth,

    ERAD or other way is all run when customer test in lab or debug. Do you know a register or memory / Interupt when customer product RTM, it can read any timer to track whether stack overflow, then can make sure system is safe, not be watchdog reset that time?

    Thanks
    BR
    Joe
  • Hi Joe, Stephan,

    Chapter 11.5.1 of the F28004x TRM outlines the programming sequence to configure the ERAD Comparator unit (register name: ERAD_HWBP_REGS) as a hardware watchpoint. The one difference between the programming sequence for debug vs application mode is that the global owner should be set to application. Otherwise, the same ERAD registers being configured by the JavaScript file should instead be configured by register writes (like register writes for other C2000 peripherals) in the customer’s application code. This can be configured to generate RTOSINT. Let me know if I clarify on the steps in the programming sequence. The ERAD register header files can also be found in C2000Ware:
    Driverlib header: C:\ti\c2000\C2000Ware_1_00_05_00\driverlib\f28004x\driverlib\inc\hw_erad.h
    Bit-field device support header: C:\ti\c2000\C2000Ware_1_00_05_00\device_support\f28004x\headers\include\f28004x_erad.h

    Regards,
    Elizabeth

  • Okay, thanks, I will look into the ERAD module then!
  • Here are my results so far:

    Setting up stack overflow detection for the application via ERAD works basically the same as via watchpoint in the C28x Analysis Block.

    The only problem is the GLBL_OWNER when debugger is connected - it is not possible for the application to gain ownership in this case. GLBL_OWNER stays at 2 (debugger). It can be changed to 0 or 1 (owner=application) via debugger, but not via application code. HWBP_MASK and HWBP_REF can't be set via application if GLBL_OWNER==2. This prevents stack overflow detection via application code when debugger is connected.

    This is different to the stack overflow detection via watchpoint in the C28x Analysis Block.

  • Hi Stephan,

    Both application and debugger can't use the ERAD at the same time. If the debugger will be connected, what's the reason to configure the ERAD owner to application as opposed to using the debugger? This can give me better understanding of the use-case. Have you confirmed there's an EALLOW in the code to enable the GLBL_OWNER, HWBP_MASK and HWBP_REF writes?

    Regards,
    Elizabeth
  • Hi Elizabeth,

    configuring the ERAD via application has the advantage that we do not have to distinguish between standalone and debugger mode - we simply run the application that sets up the stack supervision and do not care about the debugger script.
    This is possible via watchpoint in the C28x Analysis Block.

    I have checked again - there is EALLOW set before GLBL_OWNER, HWBP_MASK and HWBP_REF writes.
    Can you set GLBL_OWNER to 0 or 1 via application when debugger is connected?

    Regards,
    Stephan
  • Hi Stephan,

    You don't necessarily to have to use the JavaScript file when ERAD owner is set to debugger. Setting the GLBL_OWNER to 2 with a register write in the code will enable debugger as owner, and ERAD will function in the same as way as using the JavaScript file, if the debugger is connected. The script is an example of the ERAD configuration, so the user doesn't have to configure ERAD registers in the C code.

    You can set GLBL_OWNER to 0 (no owner) when debugger is connected and the debugger will end up being owner if it is connected, and if not connected, application will take ownership. Setting GLBL_OWNER to 1 (application owned) when debugger is connected isn't a documented use-case and not guaranteed to be properly functional.

    Regards,
    Elizabeth
  • Hi Elizabeth,

    sorry, I still do not manage to set a breakpoint / watchpoint in the ERAD module via code when debugger is connected:
    After loading the application via CCS, the debugger runs to main() and stops there.
    The GLBL_OWNER is 2 (debugger).
    When I run via resume (F8) or run free (Ctrl-F8) now, the application code should set GLBL_OWNER to 0 and set HWBP_REF.
    But when halting the debugger some time later, GLBL_OWNER is still at 2 and HWBP_REF is still at 0.

    So my conclusion at the moment is: The new ERAD in the 280049 is good because it provides more available breakpoints, but it is not suited for stack overflow supervision with AND without debugger connected. For this we have to stay with the existing C28x Analysis Block.

    Regards,
    Stephan
  • Hi Stephan,

    It is unfortunate you saw this unexpected behavior when using ERAD without the associated scripts. I'm sorry I currently don't have an explanation for this. But I really appreciate you providing us this feedback and I will take a note of it. This will help the C2000 team understand what improvements can be made to the ERAD module and define software examples that will better demonstrate its usage.

    Regards,
    Elizabeth
  • Hi Elizabeth,
    thanks for that!

    Regards,
    Stephan