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.

Generate and service NMI with SYS/BIOS

Other Parts Discussed in Thread: SYSBIOS

Hello,

I tried to generate and service a NMI on a C6678. As I'm using SYS/BIOS, I've had to use the appropriate interfaces. At the moment I use a timed IPC interrupt, see below.

Hwi_Params         sHwiParams;
Hwi_Handle         HwiHandle;
Error_Block     ErrorBlock;

Error_init(&ErrorBlock);
Hwi_Params_init(&sHwiParams);
sHwiParams.arg = 9;
sHwiParams.eventId = CSL_GEM_IPC_LOCAL;
sHwiParams.enableInt = true;
HwiHandle = Hwi_create(5, IPCHandler, &sHwiParams, &ErrorBlock);
if(HwiHandle == NULL)
{
    setStatus(&uiIRQStatus, IRQ_ERROR_IPC_SETUP_FAILED, 0, DSP_IRQ_ERROR, 0);
    return false;
}
Hwi_enable();

This code cannot be reused as no eventId is given for the NMI. Instead of this, I use the NMIGR(x) to generate the interrupt. I tried to register the ISR like this (http://e2e.ti.com/support/dsp/c6000_multi-core_dsps/f/639/t/276577.aspx):
var Exception = xdc.useModule('ti.sysbios.family.c64p.Exception');
Exception.nmiHook = '&myNmiHookFxn';

But this ISR is not recognized and I end up with this:

Exception at 0xc087d54
EFR=0x80000000 NRP=0xc087d54
Legacy NMI Exception
ti.sysbios.family.c64p.Exception: line 255: E_exceptionMin: pc = 0x00000000, sp = 0x0c0b5c74.
To see more exception detail, use ROV or set 'ti.sysbios.family.c64p.Exception.enablePrint = true;'
xdc.runtime.Error.raise: terminating execution

Can somebody explain what's the correct approach to generate and service an NMI with SYS/BIOS?

Best Regards,
Bernd

  • Hi Bernd,


    I believe you need to use the exception handling module for that purpose not the HWI module. Please see the following post:

    http://e2e.ti.com/support/embedded/tirtos/f/355/t/89509.aspx

    And by the way SW centric questions will be better answered in the respective forums. In this case the TI-RTOS forum.

    Kind regards,

    one and zero

  • Hi Bernd,

    Moving this to correct forum(TI-RTOS).

    Thanks.

  • Hello one and zero,

    thanks for your answer. Reading your link (http://e2e.ti.com/support/embedded/tirtos/f/355/t/89509.aspx), the lines are already added to the config file. Furthermore in the post it is written that: "If it's an exception, the details of the exception will be printed (i.e. register dump and reason for the exception).  If it is an NMI interrupt, the user's 'nmiHook' function will be called."

    Therefore, I think I'll generate an exception instead of an interrupt by writing to the NMIGR(x). How can I accomplish it to generate an interrupt?

    Best Regards,
    Bernd

    PS: sorry for choosing the wrong forum

  • Hi Bernd,

    I'm not an SYS/BIOS expert, but my understanding is that NMI can only be handled as an exception in SYS/BIOS for C6000.

    Could someone else please comment.

    Thanks,

    one and zero

  • Hello,

    can someone please answer the open point?

    Best Regards,
    Bernd

  • Bernd,

    When are you generating the NMI?  Unless you are causing an NMI really early before BIOS has a chance to initialize its state what you did below below in .cfg file with respect to nmiHook is correct and it should have called your function myNmiHookFxn.

    var Exception = xdc.useModule('ti.sysbios.family.c64p.Exception');
    Exception.nmiHook = '&myNmiHookFxn';

    Also you do understand that there is no returning from NMI or Exceptions so you should ask yourself why you are trying to generate an NMI or exception.  These are considered fatal so the best you can do is clean up and start the program over.

    Judah

  • Hello Judah,

    I think the time for BIOS initializing and starting is enough (initializing BIOS, then calling BIOS_start -> that starts a timer which then calls an ISR. This ISR is then generation the NMI).

    But you're right to ask for my intent, because I've not known that there's no return from a NMI. My hardware-colleague will use the pin M25 (NMI) for a constant signaling of my program by generating an interrupt every 1 ms. Therefore, I wanted to simulate this behaviour by generating this NMI by software and timer.

    Question is now, if the hardware-NMI via pin M25 is also inadequate for this purpose and we should use a normal hardware interrupt via another pin or GPIO?

    Best Regards,
    Bernd

  • Hi Bernd,

    in theory you could return from an NMI since the return address is provided in the NRP register. However, an NMI is recognized within an SPLOOP operation, the behavior is the same as for an NMI with exceptions enabled. The SPLOOP operation terminates immediately. This means in that case a return is not posssible although you have a return address since the SPLOOP context is messed up. So really the NMI is not recommended to be used as an interrupt.

    As you already suggest it's much better to use a GPIO for your purpose. Each GPIO pin (GPn) can be configured to generate a CPU interrupt (GPINTn). The interrupt can be generated on the rising-edge, falling-edge, or on both edges of the GPIO signal. The edge detection logic is synchronized to the GPIO peripheral clock.

    Kind regards,

    one and zero

  • Hello,

    thanks for clarifying this issue!

    Best Regards,
    Bernd