TI E2E Community
How to handle the NMI and ILLEGAL interrupt in BIOS for c28x?
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.
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.
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?
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:
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.
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>);
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.
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:
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.
All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.
TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs andembedded processors, along with software, tools and the industry’s largest sales/support staff.