工具/软件:
尊敬的专家:
是否可以使用外部 GPIO (上升沿/下降沿)触发 NMI? 也许 ERAD 可以做到、但我找不到一个示例。
客户希望此功能与以前的设计相匹配。
此致、
挂起
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.
工具/软件:
尊敬的专家:
是否可以使用外部 GPIO (上升沿/下降沿)触发 NMI? 也许 ERAD 可以做到、但我找不到一个示例。
客户希望此功能与以前的设计相匹配。
此致、
挂起
//#############################################################################
//
// FILE: erad_ex2_bus_monitor.c
//
// TITLE: ERAD Monotoring instruction and data address buses.
//
//! \addtogroup driver_example_list
//! <h1>ERAD HWBP Monitor Program Counter</h1>
//!
//! In this example, the function delayFunction is called multiple times.
//! The function does read and writes to the global variables startCount and
//! endCount.
//!
//! The BUSCOMP1 and COUNTER1 is used to count the number of times the function
//! delayFunction was invoked. BUSCOMP2 is used to generate an interrupt when
//! there is read access to the startCount variable and BUSCOMP3 is used to
//! generate an interrupt when there is a write access to the endCount variable
//!
//! \b Watch \b Variables \n
//! - funcCount - number of times the function delayFunction was invoked
//! - isrCount - number of times the ISR was invoked
//!
//! \b External \b Connections \n
//! - None
//
//#############################################################################
//
//Included Files
//
#include "driverlib.h"
#include "device.h"
//
// Globals
//
uint32_t isrCount = 0;
uint32_t funcCount = 0;
volatile uint32_t startCount, endCount;
#define myGPIO0_GPIO_PIN_CONFIG GPIO_5_GPIO5
#define myGPIO0 5
#define myINPUTXBARINPUT0_SOURCE 5
#define myINPUTXBARINPUT0_INPUT XBAR_INPUT1
//
// Main
//
void main(void)
{
ERAD_Counter_Config sec_params;
//
// Initializes device clock and peripherals
//
Device_init();
//
// Configures the GPIO pin as a push-pull output
//
Device_initGPIO();
// GPIO5 -> myGPIO0 Pinmux
GPIO_setPinConfig(GPIO_5_GPIO5);
GPIO_writePin(myGPIO0, 0);
GPIO_setPadConfig(myGPIO0, GPIO_PIN_TYPE_STD);
GPIO_setQualificationMode(myGPIO0, GPIO_QUAL_SYNC);
GPIO_setDirectionMode(myGPIO0, GPIO_DIR_MODE_OUT);
GPIO_setControllerCore(myGPIO0, GPIO_CORE_CPU1);
XBAR_setInputPin(INPUTXBAR_BASE, myINPUTXBARINPUT0_INPUT, myINPUTXBARINPUT0_SOURCE);
//
// Initialise the ERAD module with the APPLICATION as the owner
//
ERAD_initModule(ERAD_OWNER_APPLICATION);
//
// Initializes PIE and clears PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initializes the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// Enable RTOS Interrupt
//
Interrupt_enable(INT_RTOS);
sec_params.event = ERAD_EVENT_INPUTXBAR0;
sec_params.event_mode = ERAD_COUNTER_MODE_RISING_EDGE;
sec_params.reference = 0x2;
sec_params.rst_on_match = true;
ERAD_configCounterInCountingMode(ERAD_COUNTER1_BASE, sec_params);
ERAD_enableNMI(ERAD_INST_COUNTER1);
ERAD_enableModules(ERAD_INST_COUNTER1);
EINT;
ERTM;
while(1)
{
// Once
DEVICE_DELAY_US(100);
GPIO_writePin(myGPIO0, 1);
DEVICE_DELAY_US(100);
GPIO_writePin(myGPIO0, 0);
DEVICE_DELAY_US(100);
ESTOP0;
// Twice
GPIO_writePin(myGPIO0, 1);
DEVICE_DELAY_US(100);
GPIO_writePin(myGPIO0, 0);
DEVICE_DELAY_US(100);
ESTOP0;
};
}
您好 Hang、
这使用 GPIO5 -> INPUTXBAR -> ERAD -> NMI 生成
在本示例中、我只是将 ERAD 设置为在出现两个 GPIO 上升沿时进行计数并生成 NMI。
此致、
Ryan Ma
我们发现异常是由 NMI 看门狗引起的复位引起的。 添加了 SysCtl_clearAllNMIFlags(); 最终目的 interrupt_nmiHandler 及时停止 NMI 看门狗计数。 但同时发现了一个新问题。 当程序再次循环运行时、无法再次触发 NMI。 你知道什么原因吗? 期待您的答复。
您需要清除 ERAD 事件、因为它已被触发且事件已被触发。 要再次触发、您需要将其清除。
