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.
Tool/software: Code Composer Studio
Dear Todd,
As we know, it's necessary to create Hwis for PIE interrupts in SYS/BIOS project. Nonetheless, what should I do with watchdog interrupt or other system exceptions like NMI interupts?
Could I do with them like what I do in C2000ware project? Or should I create Hwis or Swis for them? Is there sample for it?
Thanks!
QL
QL,
Can you please describe how you will be using the watchdog? For example are you wanting to know how to detect if it reset the CPU? Or are you wanting to respond to an interrupt that a watchdog reset the other CPU?
Also, can you clarify “like what I do in C2000ware project”? Is there a sample project you are referring to?
Thanks,
Scott
Hi Scott,
I want to use Watchdog just like the example project below from C2000ware:
//############################################################################# // // FILE: watchdog_ex1_service.c // // TITLE: Servicing Watchdog Example // //! \addtogroup driver_example_list //! <h1> Watchdog </h1> //! //! This example shows how to service the watchdog or generate a wakeup //! interrupt using the watchdog. By default the example will generate a //! Wake interrupt. To service the watchdog and not generate the interrupt, //! uncomment the SysCtl_serviceWatchdog() line in the main for loop. //! //! \b External \b Connections \n //! - None. //! //! \b Watch \b Variables \n //! - wakeCount - The number of times entered into the watchdog ISR //! - loopCount - The number of loops performed while not in ISR //! // //############################################################################# // $TI Release: F2838x Support Library v2.00.00.03 $ // $Release Date: Sun Sep 29 07:45:41 CDT 2019 $ // $Copyright: // Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/ // // 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. // $ //############################################################################# // // Included Files // #include "driverlib.h" #include "device.h" // // Globals // uint32_t wakeCount; uint32_t loopCount; // // Function Prototypes // __interrupt void wakeupISR(void); // // Main // void main(void) { // // Initialize device clock and peripherals // Device_init(); // // Initialize PIE and clear PIE registers. Disables CPU interrupts. // Interrupt_initModule(); // // Initialize the PIE vector table with pointers to the shell Interrupt // Service Routines (ISR). // Interrupt_initVectorTable(); // // Re-map watchdog wake interrupt signal to call the ISR function in this // example // Interrupt_register(INT_WAKE, &wakeupISR); // // Clear the counters // wakeCount = 0; loopCount = 0; // // Set the watchdog to generate an interrupt signal instead of a // reset signal // SysCtl_setWatchdogMode(SYSCTL_WD_MODE_INTERRUPT); // // Enable the watchdog wake interrupt signal // Interrupt_enable(INT_WAKE); // // Enable Global Interrupt (INTM) and realtime interrupt (DBGM) // EINT; ERTM; // // Reset the watchdog counter // SysCtl_serviceWatchdog(); // // Enable the watchdog // SysCtl_enableWatchdog(); // // Loop till the specified LOOP_COUNT value. // for(;;) { loopCount++; // // Uncomment SysCtl_serviceWatchdog to just loop here. // Comment SysCtl_serviceWatchdog to have watchdog timeout and trigger // an interrupt signal to execute the wakeupISR // // SysCtl_serviceWatchdog(); } } // // Wakeup ISR - The interrupt service routine called when the watchdog // triggers the wake interrupt signal // __interrupt void wakeupISR(void) { wakeCount++; // // Acknowledge this interrupt located in group 1 // Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1); } // // End of File //
Thanks!
QL
Hi QL,
OK, thank you.
Since you are using the watchdog in interrupt mode instead of reset mode, you can create a Hwi for it, similar to what you do for other peripheral interrupts.
Regards,
Scott
Hi Scott,
Thanks a lot for your advice. What about other NMI interrupt? If I want to cope with corresponding NMI and do something (i.e. protection mechanism) especially for them, what should I do with them in BIOS. Also should I use Hwis or not?
Thanks again!
QL
Hi QL,
Yes you can use the Hwi module to catch an NMI. Since this is not a ‘normal’ interrupt it is configured differently. Instead of using Hwi_create() you need to ‘plug’ a handler to catch the NMI.
To plug the NMI at runtime, in your C file you can do something like this:
#include <ti/sysbios/family/c28/Hwi.h>
…
Hwi_plug(18, <your NMI function>);
If you want to plug the NMI statically in your application configuration script, you can do something like this:
var Hwi = xdc.useModule('ti.sysbios.family.c28.Hwi');
…
Hwi.plugMeta(18, <your NMI function>);
To test this you can use a TRAP or INTR instruction to activate the handler, for example:
asm(" TRAP #18");
Here are a couple of forum links for reference:
https://e2e.ti.com/support/legacy_forums/embedded/tirtos/f/355/t/182614?How-to-handle-the-NMI-and-ILLEGAL-interrupt-in-BIOS-for-c28x-
https://e2e.ti.com/support/legacy_forums/embedded/tirtos/f/355/t/365033?NMI-Event-Handling-with-SYSBIOS-6-40
Regards,
Scott