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.

Enabling NMI on TM4C1294NCPDT

Other Parts Discussed in Thread: TM4C1294NCPDT, SYSBIOS

MCU: TM4C1294NCPDT

CCS: v6.0.1.0040

-

Hi,

    I am trying to enable the NMI functionality of the TM4C1294NCPDT MCU using the following code, but due to some reason (which I am unable to figure out), its NOT working.

-

// Enable NMI
HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;//0x4C4F434B
HWREG(GPIO_PORTD_BASE + GPIO_O_CR) |= 0x80;
HWREG(GPIO_PORTD_BASE + GPIO_O_AFSEL) |= 0x80;
HWREG(GPIO_PORTD_BASE + GPIO_O_DEN) |= 0x80;
HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = 0;
//
GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_7);//PWR_FAIL_DETECT_IN,
GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_7, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPD);

-

    I have connected a switch externally with the PD7 pin of the MCU & verified that normally (when the switch is NOT pressed) the voltage at pin PD7 is 0 volts & upon switch press the voltage at the pin PD7 becomes 3.3 volts. Now, when the MCU is running the firmware, the switch press is having NO effect.

    Can anyone help me in figuring out what is going wrong? Or am I missing something somewhere?

I read through a few other posts, but it didn't help!!

-

Thanks

-

Regards

Soumyajit

  • Hello Soumyajit,

    A good read on the use of NMI.

    e2e.ti.com/.../389894

    Regards
    Amit
  • Might this be a good example of poster having (mistakenly) unlocked the MCU from it's "normal" NMI behavior? Pure poetic justice!

    Suggest this post be filed under, "Man bites dog!"
  • Hi Amit,

       I got the NMI enabled ("GPIOPinConfigure(GPIO_PD7_NMI);" was missing in my code). Now I am unable to place the function that's going to get triggered upon occurance of the NMI. The function I wrote is "void NmiSR(void)", but how do I let the system know that this function needs to run upon NMI?

       I tried from the XDC tool to create a new Hwi object but the setting of "Interrupt Number" in "TI-RTOS > Products > SYSBIOS > Scheduling > Hwi - Instance Setting" won't allow setting of Interrupt Number = 2 (2 is the vector of NMI). It says, Interrupt Number has to be greater than 15!!!

    -

    Thanks

    -

    Regards

    Soumyajit

  • Hello Soumyajit,

    E2E Forum Search...

    e2e.ti.com/.../375721

    Regards
    Amit
  • Hi Amit,

       I tried to put Hwi.nmiFunc = "&NmiSR"; at the last line of my .cfg file & now the compiler generates two errors as follows:

    1. ti.sysbios.hal.Hwi: no element named 'nmiFunc'

    2. XDC runtime error: ti.sysbios.hal.Hwi: no element named 'nmiFunc'


  • Hello Soumyajit,

    I think it should be m3Hwi.nmiFunc instead of Hwi.nmiFunc. I don't have a ready project to test it with it.

    Regards
    Amit
  • Hi Amit,

       Compiler says "m3Hwi" is not defined !!

    -

    Thanks

    -

    Regards

    Soumyajit

  • Hi Amit,

       I missed out "var m3Hwi = xdc.useModule('ti.sysbios.family.arm.m3.Hwi');", but now the error shown is:

    "identifier "NmiSR" is undefined" for the statement "m3Hwi.nmiFunc = "&NmiSR";".

    In my main.c file, I have:

    void NmiSR(void);

    void NmiSR(void)

    {

    // GPIOPinConfigure(GPIO_PD7_U2TX);

    GPIO_write(LED_RUN_OUT, PIN_LOW);

    GPIO_write(LED_ERROR_OUT, PIN_HIGH);

    while(1);

    }

    -

    Can you suggest what might be going wrong?

    -

    Thanks

    -

    Regards

    Soumyajit

  • Hello Soumyajit,

    That is exactly where I ended up. I have asked the same question on TI-RTOS forum as well. You may want to track the same

    e2e.ti.com/.../375721

    Regards
    Amit
  • Hi Amit,
    I will wait for a response!!
    -
    Thanks
    -
    Regards
    Soumyajit
  • Hi Amit,

      Posting a copy of the *.cfg file contents:

    /*
    * Copyright (c) 2013, Texas Instruments Incorporated
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    * * Neither the name of Texas Instruments Incorporated nor the names of
    * its contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */

    /*
    * ======== fatsdusbcopy.cfg ========
    */

    /* ================ General configuration ================ */
    var Defaults = xdc.useModule('xdc.runtime.Defaults');
    var Diags = xdc.useModule('xdc.runtime.Diags');
    var Error = xdc.useModule('xdc.runtime.Error');
    var Log = xdc.useModule('xdc.runtime.Log');
    var Main = xdc.useModule('xdc.runtime.Main');
    var Memory = xdc.useModule('xdc.runtime.Memory');
    var System = xdc.useModule('xdc.runtime.System');
    var Text = xdc.useModule('xdc.runtime.Text');

    var Task = xdc.useModule('ti.sysbios.knl.Task');
    var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');
    var FatFS = xdc.useModule('ti.sysbios.fatfs.FatFS');
    var m3Hwi = xdc.useModule('ti.sysbios.family.arm.m3.Hwi');

    var Mailbox = xdc.useModule('ti.sysbios.knl.Mailbox');
    var UART = xdc.useModule('ti.drivers.UART');
    var I2C = xdc.useModule('ti.drivers.I2C');
    var SPI = xdc.useModule('ti.drivers.SPI');
    var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
    var EMAC = xdc.useModule('ti.drivers.EMAC');
    var Global = xdc.useModule('ti.ndk.config.Global');
    var Ip = xdc.useModule('ti.ndk.config.Ip');
    var Http = xdc.useModule('ti.ndk.config.Http');

    /* System stack size (used by ISRs and Swis) */
    Program.stack = 8192;//0x300;

    /*
    * Comment this line to allow module names to be loaded on the target.
    * The module name strings are placed in the .const section. Setting this
    * parameter to false will save space in the .const section. Error and
    * Assert messages will contain an "unknown module" prefix instead
    * of the actual module name.
    */
    Defaults.common$.namedModule = false;

    /*
    * Minimize exit handler array in System. The System module includes
    * an array of functions that are registered with System_atexit() to be
    * called by System_exit().
    */
    System.maxAtexitHandlers = 2;

    /*
    * Comment this line to allow Error, Assert, and Log strings to be
    * loaded on the target. These strings are placed in the .const section.
    * Setting this parameter to false will save space in the .const section.
    * Error, Assert and Log message will print raw ids and args instead of
    * a formatted message.
    */
    Text.isLoaded = true;//false;

    /* ================ System configuration ================ */
    var SysStd = xdc.useModule('xdc.runtime.SysStd');
    System.SupportProxy = SysStd;

    /* ================ BIOS configuration ================ */
    /*
    * Disable unused BIOS features to minimize footprint.
    * This example uses Tasks but not Swis or Clocks.
    */
    var BIOS = xdc.useModule('ti.sysbios.BIOS');
    BIOS.libType = BIOS.LibType_Custom;
    BIOS.swiEnabled = true;//false;
    BIOS.logsEnabled = false;
    BIOS.assertsEnabled = false;

    /* Declare the heap size */
    BIOS.heapSize = 22528;

    /* No runtime stack checking is performed */
    Task.checkStackFlag = false;
    Hwi.checkStackFlag = false;

    /* Reduce the number of task priorities */
    Task.numPriorities = 16;

    /* Remove the Idle Task */
    Task.enableIdleTask = true;//false;

    //var mboxParam = new Mailbox.Params();

    //m3Hwi.resetVectorAddress = 0x8000; // App base

    /* ================ Task configuration ================ */
    var taskParams = new Task.Params();
    taskParams.instance.name = "fatsdUSBCopyTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&taskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "lcdTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 9;
    Program.global.task = Task.create("&lcdTaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "com0Task";
    taskParams.stackSize = 8000;//0x400;
    taskParams.priority = 5;
    Program.global.task = Task.create("&com0TaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "ExtRtcTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 9;
    Program.global.task = Task.create("&extRtcTaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "KeyTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 10;
    Program.global.task = Task.create("&keyTaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "AdcCh16Task";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&adcCh16TaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "AdcCh4Task";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&adcCh4TaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "DataLogTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&dataLogTaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "SdCardLogTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&sdCardLogTaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "DigitalInputTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&DigInputTaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "Sdi12Task";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&sdi12TaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "DigitalOutputTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&DigOutputTaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "UserInterfaceTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&userInterfaceTaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "AlarmTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&alarmTaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "GpsTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&gpsTaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "GpsTimeUpdateTriggerTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&gpsTimeUpdateTriggerTaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "SerialFlashTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&serialFlashTaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "TestTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&testTaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "LCDTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 5;
    Program.global.task = Task.create("&LCDTaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "GsmTask";
    taskParams.stackSize = 4000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&gsmTaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "HmiTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&hmiTaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "TcpOutgoingTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&tcpOutgoingTaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "SfLogTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&sfLogTaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "SfDebugStoreTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&sfDebugStoreTaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "SfDebugRestoreTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&sfDebugRestoreTaskFxn", taskParams);

    var taskParams = new Task.Params();
    taskParams.instance.name = "QeiTask";
    taskParams.stackSize = 2000;//0x400;
    taskParams.priority = 3;
    Program.global.task = Task.create("&qeiTaskFxn", taskParams);

    /* ================ Driver configuration ================ */
    var TIRTOS = xdc.useModule('ti.tirtos.TIRTOS');
    var GPIO = xdc.useModule('ti.drivers.GPIO');
    var SDSPI = xdc.useModule('ti.drivers.SDSPI');
    var USBMSCHFatFs = xdc.useModule('ti.drivers.USBMSCHFatFs');
    GPIO.libType = GPIO.LibType_NonInstrumented;
    SDSPI.libType = SDSPI.LibType_NonInstrumented;
    USBMSCHFatFs.libType = USBMSCHFatFs.LibType_NonInstrumented;
    var mailbox0Params = new Mailbox.Params();
    mailbox0Params.instance.name = "mboxLcd";
    Program.global.mboxLcd = Mailbox.create(22, 12, mailbox0Params);
    UART.libType = UART.LibType_NonInstrumented;
    I2C.libType = I2C.LibType_NonInstrumented;
    SPI.libType = SPI.LibType_NonInstrumented;
    var semaphore0Params = new Semaphore.Params();
    semaphore0Params.instance.name = "mtxMdoAdc4Ch";
    semaphore0Params.mode = Semaphore.Mode_BINARY;
    Program.global.mtxMdoAdc4Ch = Semaphore.create(1, semaphore0Params);
    var semaphore1Params = new Semaphore.Params();
    semaphore1Params.instance.name = "mtxMdoAdc16Ch";
    semaphore1Params.mode = Semaphore.Mode_BINARY;
    Program.global.mtxMdoAdc16Ch = Semaphore.create(1, semaphore1Params);
    var semaphore2Params = new Semaphore.Params();
    semaphore2Params.instance.name = "semDataLog";
    semaphore2Params.mode = Semaphore.Mode_BINARY;
    Program.global.semDataLog = Semaphore.create(null, semaphore2Params);
    var semaphore3Params = new Semaphore.Params();
    semaphore3Params.instance.name = "mtxSdCardAccess";
    semaphore3Params.mode = Semaphore.Mode_BINARY;
    Program.global.mtxSdCardAccess = Semaphore.create(1, semaphore3Params);
    var semaphore4Params = new Semaphore.Params();
    semaphore4Params.instance.name = "semOneSecTickForDataLogging";
    Program.global.semOneSecTickForDataLogging = Semaphore.create(null, semaphore4Params);
    var semaphore5Params = new Semaphore.Params();
    semaphore5Params.instance.name = "semSdCardActivityTrigger";
    semaphore5Params.mode = Semaphore.Mode_BINARY;
    Program.global.semSdCardActivityTrigger = Semaphore.create(null, semaphore5Params);
    var mailbox1Params = new Mailbox.Params();
    mailbox1Params.instance.name = "mboxUiIncoming";
    Program.global.mboxUiIncoming = Mailbox.create(256, 1, mailbox1Params);
    var mailbox2Params = new Mailbox.Params();
    mailbox2Params.instance.name = "mboxUiOutgoing";
    Program.global.mboxUiOutgoing = Mailbox.create(256, 1, mailbox2Params);
    var mailbox3Params = new Mailbox.Params();
    mailbox3Params.instance.name = "mboxSetRtc";
    Program.global.mboxSetRtc = Mailbox.create(30, 1, mailbox3Params);
    var mailbox4Params = new Mailbox.Params();
    mailbox4Params.instance.name = "mboxSd2UsbCopy";
    Program.global.mboxSd2UsbCopy = Mailbox.create(50, 1, mailbox4Params);
    var mailbox5Params = new Mailbox.Params();
    mailbox5Params.instance.name = "mboxAlarmLog";
    Program.global.mboxAlarmLog = Mailbox.create(50, 20, mailbox5Params);
    var semaphore6Params = new Semaphore.Params();
    semaphore6Params.instance.name = "semOneSecTickForGpsTimeUpdate";
    Program.global.semOneSecTickForGpsTimeUpdate = Semaphore.create(null, semaphore6Params);
    var semaphore7Params = new Semaphore.Params();
    semaphore7Params.instance.name = "semGpsTimeUpdateRequest";
    semaphore7Params.mode = Semaphore.Mode_BINARY;
    Program.global.semGpsTimeUpdateRequest = Semaphore.create(0, semaphore7Params);
    var semaphore8Params = new Semaphore.Params();
    semaphore8Params.instance.name = "semSfActivityTrigger";
    semaphore8Params.mode = Semaphore.Mode_BINARY;
    Program.global.semSfActivityTrigger = Semaphore.create(null, semaphore8Params);
    EMAC.libType = EMAC.LibType_NonInstrumented;
    Global.IPv6 = false;
    Ip.autoIp = false;
    Ip.address = "192.168.1.1";
    Ip.mask = "255.255.255.0";
    Ip.gatewayIpAddr = "192.168.1.2";
    Ip.domainName = "mydomain.com";
    var http0Params = new Http.Params();
    var http0 = Http.create(http0Params);
    Global.lowTaskPriLevel = 3;
    Global.stackInitHook = "&AddWebFiles";
    Global.stackDeleteHook = "&RemoveWebFiles";
    var semaphore9Params = new Semaphore.Params();
    semaphore9Params.instance.name = "semOneSecTickForGsmGprs";
    Program.global.semOneSecTickForGsmGprs = Semaphore.create(null, semaphore9Params);
    var semaphore10Params = new Semaphore.Params();
    semaphore10Params.instance.name = "semSfLogActivityTrigger";
    semaphore10Params.mode = Semaphore.Mode_BINARY;
    Program.global.semSfLogActivityTrigger = Semaphore.create(null, semaphore10Params);
    var mailbox6Params = new Mailbox.Params();
    mailbox6Params.instance.name = "mboxDebugStore";
    Program.global.mboxDebugStore = Mailbox.create(32, 10, mailbox6Params);
    var semaphore11Params = new Semaphore.Params();
    semaphore11Params.instance.name = "semSfDbgRead";
    Program.global.semSfDbgRead = Semaphore.create(null, semaphore11Params);
    Global.networkIPAddrHook = "&mynetworkIPAddrHook";
    Global.networkOpenHook = "&functionNetworkOpenHook";
    m3Hwi.nmiFunc = "&NmiSR";

    -

    Thanks

    -

    Regards

    Soumyajit

  • Hello Soumyajit

    Post it in the TI-RTOS Forum

    Regards
    Amit