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.

How to handle the NMI and ILLEGAL interrupt in BIOS for c28x?

Other Parts Discussed in Thread: SYSBIOS

Currently I am running  the SysBios 6.32.05.54 with CCS5.1 on 28335 PGF ControlCard.

I am trying to use the following code(devide by 0, and accessing invalid address)

to see what is the behavior of the system.

	UInt32 i = 1,tt,*pAdd =(UInt32*)0x300000 ;

i = i/3;
tt = (loopCnt/i);
*pAdd = tt;

But I found the program can run without any stop even with some devide-by-zero overflow .
Neither NMI and ILLEGAL interrupt was triggered.

I try to search how to handle the NMI and ILLEGAL interrupt in BIOS for c28x, but no useful information found yet:(
Is their anyone knowing the answer or having these experience?
Thanks in advance!
  • Hi tony chen,

    I will have to try something similar locally to see if I see the same results.  I'll try that and get back to you as soon as I can.

    Steve

  • tony chen,

    I was able to reproduce the problem you are seeing.  I also see that the divide by 0 is happening, however the program continues on.

    I noticed that the value of 'tt' in:

    tt = (loopCnt/i);

    becomes 0xFFFFFFFF.  It may be that this is the defined result for divide by 0 on the C28x.

    Furthermore, I don't believe this is a BIOS issue, so I will request that it is forwarded to the compiler forums; they may have some further insight on this.

    Steve

  • The C standard says that integer division by zero is undefined behavior.  This means that the implementation (compiler+linker+library) is free to do anything at all, and may do something different every time.  Strictly conforming programs are not allowed to expect any particular behavior, including a raised signal.   Some implementations do raise a signal upon integer divide-by-zero (particularly those that have division implemented as a CPU instruction), but the TI implementation does not.  The C2800 implementation does return 0xFFFFFFFF, but that is strictly to prevent an infinite loop in the division function.  Programs should not rely on this value; they should test the divisor for zero before the division.  Anything else is non-portable.

    In short: do not divide integers by zero.

  • If the devide by 0 operation will not trigger any interrupt,

    How about accessing the invalid address ?

    What's the use of NMI and ILLEGAL interrupt  for c28x?

    And how to handle these two interrupts in BIOS?

  • Hi tony chen,

    You can use the BIOS configuration tool to handle an NMI interrupt.

    For example, if I open a C28x based BIOS configuration file (*.tcf file), I see this under the HWI manager:

    You can configure the "function" property so that it will run a particular function when triggered.  Similar for ILLEGAL.

    Please also see this document for some more information:

    http://www.ti.com/lit/ug/spru430e/spru430e.pdf

    Steve

  • Hi Steve,

    I am using SysBios 6.32.05.54 with CCS5.1, in the CCS5.1, all the BIOS hwi needs to be added by assigning the interrupt number to a function manually.

    When I created a new hwi with the int number 18 (NMI for 28335), the following picture showed.

  • Hi Tony,

    Can you try adding the following into the code of your *.cfg file?  You will need to replace "<your ISR function>" with the name of the ISR function that you want to run when the NMI is triggered.

    var Hwi = xdc.useModule('ti.sysbios.family.c28.Hwi');

    Hwi.plugMeta(18, <your ISR function>);

    Steve

  • Hi Steve,

    Thanks, it works.

    By using asm(" INTR NMI"); I was able to trigger my NMI ISR.

    But I didnt find any GUI interface showing the NMI and ILLEAGLE interrupt status in CCS 5 yet.

    B&R

    tony

  • Tony,

    An ILLEGAL trap (or ITRAP) happens when an illegal opcode is executed.  Often this is due to the PC going off into the weeds due to a stack overflow or buffer overflow.  There is some more information on this wiki page:

    http://processors.wiki.ti.com/index.php/Interrupt_FAQ_for_C2000#The_ITRAP_Interrupt

    For NMI - on the 2833x devices you can configure which pin on port A will be connected to NMI - this is described in www.ti.com/lit/sprufb0

    Search for GPIOXNMISEL.

    Unfortunately I'll have to defer to other experts on the CCS 5 / BIOS question.

    -Lori