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.

NMI Event Handling with SYSBIOS 6.40

Other Parts Discussed in Thread: SYSBIOS

Hi,

I am using SYSBIOS 6.40 and the TMS320F28377.  

I understand from the API reference guide, that: 

"On the C28x, DSP/BIOS does not support returning from an NMI interrupt when the PIE is enabled and
other interrupts are using the dispatcher." 

This explains behaviour that I see in my code.   I try to Force an NMI (while I'm in a Timer 0 Swi) and then clear it.  However, I can't return to my code.  I either go to "void abort(void)" in "Exit.c" or I get a message - I forget exactly what the message says but the code exits and gives some message with an address.   

If an NMI occurs I would like to detect it and shutdown my system hardware in a safe manner and do some logging functions before the software exits.    

I saw a post related to this for the C6000 family:

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

But can't find any documentation for the C28x.  

How do I call some code to shutdown and log stuff if an NMI occurs on the 28377 architecture with SYSBIOS?  Also, is there any SYSBIOS application code or documentation about NMIs or exception handling that I can follow?  I don't see any documentation about exception handling.  I tried to turn on Hwi number 18 (NMI) but app.cfg interface doesn't let me do that.  

Thanks,

Rick 

  • Hi Rick,

    I think you should be able to map an ISR to the NMI at runtime using the SYS/BIOS API Hwi_plug().  The Hwi_create() API won't let you do it, as it only allows creation of maskable interrupts, whose interrupt numbers are less than 15.

    Based on spru430e.pdf, Table 3-1, it looks like the interrupt number for NMI on C28x should be 18.

    Can you try calling Hwi_plug() to map interrupt 18 to your own ISR?  Hopefully your mapped ISR will run when the NMI occurs, then in your ISR, you can try doing your logging, etc.

    Steve

  • Hi Steve,

    Yes, this works.  Excellent support.  

    I just added

    Hwi_plug(18,  NMI_ISR_Fcn);

    to my startup c code, and everything works.  When I force the NMI I do enter my NMI_ISR_Fcn function.  So that's great.    

    One thing that I'm not sure I did right is that the literature at

    http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/sysbios/6_34_05_24/exports/bios_6_34_05_24/docs/cdoc/ti/sysbios/family/c28/Hwi.html#xdoc-desc

    says to use Hwi_enableIER(mask) before using Hwi_plug().  

    I'm not sure what to send for the mask value.  Question, would I use the following to enable interrupt 18?  

    Hwi_enableIER(0x0012) 

    However, my code is working without using Hwi_enable, I'm just not sure if I need this.  

    I do use the following in my c init code already:

    EALLOW;
    NmiIntruptRegs.NMICFG.bit.NMIE = 1;
    NmiIntruptRegs.NMIFLGCLR.bit.NMIINT = 1;
    EDIS;

    If you know what to send for that mask value, please let me know, otherwise everything appears to be working great.  

    Thanks Steve,

    Rick 

  • Rick,

    Rick Crispo said:

     Question, would I use the following to enable interrupt 18?  

    Hwi_enableIER(0x0012) 

    You've almost got it.  0x12 = 18 dec = 10010 binary.  But, that argument corresponds to a bit mask, so this will enable interrupts 1 and 4.

    I think you should use something like this to enable interrupt 18 (NMI):

            int intNum = 18;        

            int enableMask = 1 << (intNum - 1);
            key = Hwi_enableIER(enableMask);


    Steve