EINT、DINT、ERTM、DRTM和INTM、DBGM解析

本文介绍了DSP中的中断全局屏蔽位INTM和调试启用屏蔽位DBGM的作用及使用方法。INTM用于控制所有可屏蔽中断的全局使能或禁止状态,而DBGM则用于控制调试事件的使能或禁止。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、参考DSP281x_Device.h
#define  EINT   asm(" clrc INTM")  //INTM置0,开中断
#define  DINT   asm(" setc INTM")  //INTM置1,关中断
#define  ERTM   asm(" clrc DBGM")  //使能调试事件
#define  DRTM   asm(" setc DBGM")  //禁止调试事件
二、参考《TMS320C28x DSP CPU和指令集参考指南》中对INTM和DBGM的解释
1、DBGM
Bit 1:调试启用屏蔽位。当DBGM置位时,仿真器无法在实时状态下访问内存或寄存器。调试器无法更新其窗口。
    在实时调试模式中,若DBGM = 1,则CPU忽略停止请求或硬件断点,直到DBGM清零。DBGM并不阻止CPU停止在软件断点。这点的一个影响可以在实时调试模式中看到。如果你在实时调试模式中单步执行一个指令,并且这条指令置位DBGM,CPU继续执行指令,直到DBGM被清零。
    当你给TI调试器“实时”命令时(进入实时模式),DBGM强制为0。令DBGM = 0确保了允许调试和测试直接内存访问 (DT-DMAs);内存和寄存器的值可传递到主处理器,用于更新调试器窗口。
    CPU在执行中断服务程序(ISR)之前将DBGM置位。当DBGM = 1时,来自主处理器和硬件断点的停止请求被忽略。如果你想要单步执行程序或在对时间要求不严格的ISR中设置断点,那么你必须在ISR的开始处增加一条CLRC DBGM指令。
    DBGM主要用在时间要求严格的程序代码部分的仿真,来阻止调试事件。DBGM使能或禁止调试事件,如下:
  调试事件使能。
  调试事件禁止。
    当CPU响应中断时,DBGM的当前值存储到堆栈中(当ST1存储在堆栈中时),然后DBGM置位。当由中断返回时,DBGM由堆栈中恢复。
    此位可分别由SETC DBGM指令和CLRC DBGM指令复位和清零。DBGM在中断操作期间被自动置位。复位时,DBGM置位。执行ABORTI (中止中断)指令也可以将DBGM置位。
2、INTM
Bit 0:中断全局屏蔽位。此位从全局上使能或禁止所有可屏蔽CPU中断(那些可由软件阻止的中断):
  可屏蔽中断被全局使能。为了被CPU认可,则可屏蔽中断也必须被中断使能寄存器(IER)局部使能。
  可屏蔽中断被全局禁止。即使一个可屏蔽中断被IER局部使能,也不会被CPU认可。
    INTM对非可屏蔽中断没有影响,包括硬件复位或软件复位中断NMI。此外,当CPU在实时仿真模式下被停止时,由IER和DBGIER使能的中断将被响应,即使INTM设置为禁止可屏蔽中断。
    当CPU响应中断时,INTM的当前值存储到堆栈中(当ST1存储在堆栈中时),然后INTM置位。当由中断返回时,INTM由堆栈中恢复。
    此位可分别由SETC INTM指令和CLRC INTM指令复位和清零。复位时,INTM置位。INTM的值不会引起中断标志寄存器(IFR)、中断使能寄存器(IER)或调试中断使能寄存器(DBGIER)
的改变。
看 main() 函数:初始化顺序(时钟→GPIO→PWM→ADC→中断→外设) 主循环 while(1) 里干啥(通常非实时任务,如保护检测)。关键线索: 找到 中断服务函数(ISR)的名字(比如 PWM1_ISR 或 adc_isr()) 代码如下: #include "DSP28x_Project.h" // Device Headerfile and Examples Include File #include <stdio.h> #include <math.h> // Prototype statements for functions found within this file. /*void InitEPwm1Example(void); void InitEPwm2Example(void); void InitEPwm3Example(void); */ interrupt void epwm1_isr(void); interrupt void adc_isr(void); /*void InitEPwm1SPWM(void); void InitEPwm2SPWM(void); void InitEPwm3SPWM(void); void InitEPwm4SPWM(void); void InitEPwm5SPWM(void); void InitEPwm6SPWM(void); */ //extern volatile Uint16 ePWM_Timer_TBPRD;//? void main(void) { InitSysCtrl(); //第一:初始化PLL得SYSCLKOUT=150MHz,看门狗。且使能ePWM模块时钟。 //更改高速时钟预定标寄存器的值。 EALLOW; SysCtrlRegs.HISPCP.all = 0x3; // HSPCLK = SYSCLKOUT/2*3=25MHZ EDIS; InitEPwmGpio(); InitTzGpio(); //第二:初始化GPIO口,将EPwm设为EPwm输出。 // 第三:中断初始化 Clear all interrupts and initialize PIE vector table: // Disable CPU interrupts DINT; // This function is found in the DSP2833x_PieCtrl.c file. InitPieCtrl(); // Disable CPU interrupts and clear all CPU interrupt flags: IER = 0x0000; IFR = 0x0000; InitPieVectTable(); EALLOW; PieVectTable.EPWM1_INT = &epwm1_isr; PieVectTable.ADCINT = &adc_isr; EDIS; // This is needed to disable write to EALLOW protected registers //ePWM模块的初始化 EALLOW; SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0; EDIS; InitEPwm(); InitAdc(); EALLOW; SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;//目的就是保证ePWM各模块时钟同步 EDIS; // Step 5. User specific code, enable interrupts // Enable CPU INT3 which is connected to EPWM1-3 INT: IER |= M_INT3; IER |= M_INT1; // Enable EPWM INTn in the PIE: Group 3 interrupt 1-3 PieCtrlRegs.PIEIER3.bit.INTx1 = 1; //使能ePWM1中断,第三行,第一个 PieCtrlRegs.PIEIER1.bit.INTx6 = 1; //使能ADC中断,第一行,第六个 // Enable global Interrupts and higher priority real-time debug events: EINT; // Enable Global interrupt INTM ERTM; // Enable Global realtime interrupt DBGM // Step 6. IDLE loop. Just sit and loop forever (optional): for(;;) { asm(" NOP"); } } //=========================================================================== // No more. //===========================================================================
06-04
//########################################################################### // // FILE: F2806x_PieVect.h // // TITLE: F2806x Devices PIE Vector Table Definitions. // //########################################################################### // $TI Release: F2806x C/C++ Header Files and Peripheral Examples V136 $ // $Release Date: Apr 15, 2013 $ //########################################################################### #ifndef F2806x_PIE_VECT_H #define F2806x_PIE_VECT_H #ifdef __cplusplus extern "C" { #endif //--------------------------------------------------------------------------- // PIE Interrupt Vector Table Definition: // // Create a user type called PINT (pointer to interrupt): typedef interrupt void(*PINT)(void); // Define Vector Table: struct PIE_VECT_TABLE { // Reset is never fetched from this table. // It will always be fetched from 0x3FFFC0 in // boot ROM PINT PIE1_RESERVED; PINT PIE2_RESERVED; PINT PIE3_RESERVED; PINT PIE4_RESERVED; PINT PIE5_RESERVED; PINT PIE6_RESERVED; PINT PIE7_RESERVED; PINT PIE8_RESERVED; PINT PIE9_RESERVED; PINT PIE10_RESERVED; PINT PIE11_RESERVED; PINT PIE12_RESERVED; PINT PIE13_RESERVED; // Non-Peripheral Interrupts: PINT TINT1; // CPU-Timer1 PINT TINT2; // CPU-Timer2 PINT DATALOG; // Datalogging interrupt PINT RTOSINT; // RTOS interrupt PINT EMUINT; // Emulation interrupt PINT NMI; // Non-maskable interrupt PINT ILLEGAL; // Illegal operation TRAP PINT USER1; // User Defined trap 1 PINT USER2; // User Defined trap 2 PINT USER3; // User Defined trap 3 PINT USER4; // User Defined trap 4 PINT USER5; // User Defined trap 5 PINT USER6; // User Defined trap 6 PINT USER7; // User Defined trap 7 PINT USER8; // User Defined trap 8 PINT USER9; // User Defined trap 9 PINT USER10; // User Defined trap 10 PINT USER11; // User Defined trap 11 PINT USER12; // User Defined trap 12 // Group 1 PIE Peripheral Vectors: PINT ADCINT1; // ADC - if Group 10 ADCINT1 is enabled, this must be rsvd1_1 PINT ADCINT2; // ADC - if Group 10 ADCINT2 is enabled, this must be rsvd1_2 PINT rsvd1_3; PINT XINT1; // External Interrupt 1 PINT XINT2; // External Interrupt 2 PINT ADCINT9; // ADC 9 PINT TINT0; // Timer 0 PINT WAKEINT; // WD // Group 2 PIE Peripheral Vectors: PINT EPWM1_TZINT; // EPWM-1 PINT EPWM2_TZINT; // EPWM-2 PINT EPWM3_TZINT; // EPWM-3 PINT EPWM4_TZINT; // EPWM-4 PINT EPWM5_TZINT; // EPWM-5 PINT EPWM6_TZINT; // EPWM-6 PINT EPWM7_TZINT; // EPWM-7 PINT EPWM8_TZINT; // EPWM-8 // Group 3 PIE Peripheral Vectors: PINT EPWM1_INT; // EPWM-1 PINT EPWM2_INT; // EPWM-2 PINT EPWM3_INT; // EPWM-3 PINT EPWM4_INT; // EPWM-4 PINT EPWM5_INT; // EPWM-5 PINT EPWM6_INT; // EPWM-6 PINT EPWM7_INT; // EPWM-7 PINT EPWM8_INT; // EPWM-8 // Group 4 PIE Peripheral Vectors: PINT ECAP1_INT; // ECAP-1 PINT ECAP2_INT; // ECAP-2 PINT ECAP3_INT; // ECAP-3 PINT rsvd4_4; PINT rsvd4_5; PINT rsvd4_6; PINT HRCAP1_INT; // HRCAP-1 PINT HRCAP2_INT; // HRCAP-2 // Group 5 PIE Peripheral Vectors: PINT EQEP1_INT; // EQEP-1 PINT EQEP2_INT; // EQEP-2 PINT rsvd5_3; PINT HRCAP3_INT; // HRCAP-3 PINT HRCAP4_INT; // HRCAP-4 PINT rsvd5_6; PINT rsvd5_7; PINT USB0_INT; // USB-0 // Group 6 PIE Peripheral Vectors: PINT SPIRXINTA; // SPI-A PINT SPITXINTA; // SPI-A PINT SPIRXINTB; // SPI-B PINT SPITXINTB; // SPI-B PINT MRINTA; // McBSP-A PINT MXINTA; // McBSP-A PINT rsvd6_7; PINT rsvd6_8; // Group 7 PIE Peripheral Vectors: PINT DINTCH1; // DMA CH1 PINT DINTCH2; // DMA CH2 PINT DINTCH3; // DMA CH3 PINT DINTCH4; // DMA CH4 PINT DINTCH5; // DMA CH5 PINT DINTCH6; // DMA CH6 PINT rsvd7_7; PINT rsvd7_8; // Group 8 PIE Peripheral Vectors: PINT I2CINT1A; // I2C-A PINT I2CINT2A; // I2C-A PINT rsvd8_3; PINT rsvd8_4; PINT rsvd8_5; PINT rsvd8_6; PINT rsvd8_7; PINT rsvd8_8; // Group 9 PIE Peripheral Vectors: PINT SCIRXINTA; // SCI-A PINT SCITXINTA; // SCI-A PINT SCIRXINTB; // SCI-B PINT SCITXINTB; // SCI-B PINT ECAN0INTA; // eCAN-A PINT ECAN1INTA; // eCAN-A PINT rsvd9_7; PINT rsvd9_8; // Group 10 PIE Peripheral Vectors: PINT rsvd10_1; // Can be ADCINT1, but must make ADCINT1 in Group 1 space "reserved". PINT rsvd10_2; // Can be ADCINT2, but must make ADCINT2 in Group 1 space "reserved". PINT ADCINT3; // ADC PINT ADCINT4; // ADC PINT ADCINT5; // ADC PINT ADCINT6; // ADC PINT ADCINT7; // ADC PINT ADCINT8; // ADC // Group 11 PIE Peripheral Vectors: PINT CLA1_INT1; // CLA PINT CLA1_INT2; // CLA PINT CLA1_INT3; // CLA PINT CLA1_INT4; // CLA PINT CLA1_INT5; // CLA PINT CLA1_INT6; // CLA PINT CLA1_INT7; // CLA PINT CLA1_INT8; // CLA // Group 12 PIE Peripheral Vectors: PINT XINT3; PINT rsvd12_2; PINT rsvd12_3; PINT rsvd12_4; PINT rsvd12_5; PINT rsvd12_6; PINT LVF; // Latched overflow PINT LUF; // Latched underflow }; //--------------------------------------------------------------------------- // PIE Interrupt Vector Table External References & Function Declarations: // extern struct PIE_VECT_TABLE PieVectTable; #ifdef __cplusplus } #endif /* extern "C" */ #endif // end of F2806x_PIE_VECT_H definition //=========================================================================== // End of file. //=========================================================================== /*===================================================================================== File name: sysInit.c Originator: Motor Control Systems Group Description: ===================================================================================== History: ------------------------------------------------------------------------------------- 04-15-2005 Version 3.20 -------------------------------------------------------------------------------------*/ #ifndef _SYSINIT_C #define _SYSINIT_C #include "pmsmahf.h" // These are defined by the linker (see F2812.cmd) extern Uint16 RamfuncsLoadStart; extern Uint16 RamfuncsLoadEnd; extern Uint16 RamfuncsRunStart; /*=====================================================================================*/ /**/ /*=====================================================================================*/ void fun_sysInit() { // ****************************************** // Initialization code for DSP_TARGET = F2812 // ****************************************** // Initialize System Control registers, PLL, WatchDog, Clocks to default state: // This function is found in the DSP281x_SysCtrl.c file. InitSysCtrl(); /* // Globally synchronize all ePWM modules to the time base clock (TBCLK) EALLOW; SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; EDIS; // HISPCP prescale register settings, normally it will be set to default values EALLOW; // This is needed to write to EALLOW protected registers SysCtrlRegs.HISPCP.all = 0x0000; // SYSCLKOUT/1 EDIS; // This is needed to disable write to EALLOW protected registers */ // Disable and clear all CPU interrupts: DINT; IER = 0x0000; IFR = 0x0000; // Initialize Pie Control Registers To Default State: // This function is found in the DSP281x_PieCtrl.c file. InitPieCtrl(); // Initialize the PIE Vector Table To a Known State: // This function is found in DSP281x_PieVect.c. // This function populates the PIE vector table with pointers // to the shell ISR functions found in DSP281x_DefaultIsr.c. InitPieVectTable(); // Copy time critical code and Flash setup code to RAM // This includes the following ISR functions: EvaTimer1(), EvaTimer2() // EvbTimer3 and and InitFlash(); // The RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart // symbols are created by the linker. Refer to the F2812.cmd file. MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart); // Call Flash Initialization to setup flash waitstates // This function must reside in RAM InitFlash(); // User specific functions, Reassign vectors (optional), Enable Interrupts: // Waiting for enable flag set // Enable CNT_zero interrupt using EPWM1 Time-base EALLOW; // This is needed to write to EALLOW protected registers EPwm1Regs.ETSEL.bit.INTEN = 1; // Enable EPWM1INT generation EPwm1Regs.ETSEL.bit.INTSEL = 1; // Enable interrupt CNT_zero event EPwm1Regs.ETPS.bit.INTPRD = 1; // Generate interrupt on the 1st event EPwm1Regs.ETCLR.bit.INT = 1; // Enable more interrupts #if HD_PHASE_OC_SOURCE==HD_PHASE_OC_HARDWARE EPwm1Regs.TZEINT.bit.OST = 1; // Enable EPWM1_TZINT generation #else EPwm1Regs.TZEINT.bit.OST = 0; // Disable EPWM1_TZINT generation #endif EPwm1Regs.TZCLR.bit.OST = 1; // Enable more interrupts EPwm1Regs.TZCLR.bit.CBC = 1; // Enable more interrupts EPwm1Regs.TZCLR.bit.INT = 1; // Enable more interrupts EDIS; // This is needed to disable write to EALLOW protected registers // Reassign ISRs. // Reassign the PIE vector for T1UFINT and CAP3INT to point to a different // ISR then the shell routine found in DSP281x_DefaultIsr.c. // This is done if the user does not want to use the shell ISR routine // but instead wants to use their own ISR. EALLOW; // This is needed to write to EALLOW protected registers PieVectTable.EPWM1_INT = &MainISR; #if HD_PHASE_OC_SOURCE==HD_PHASE_OC_HARDWARE PieVectTable.EPWM1_TZINT = &PdpintISR; #endif EDIS; // This is needed to disable write to EALLOW protected registers // Enable PIE group 3 interrupt 1 for EPWM1_INT PieCtrlRegs.PIEIER3.all = M_INT1; // Enable PIE group 2 interrupt 1 for EPWM1_TZINT PieCtrlRegs.PIEIER2.all = M_INT1; // Enable CPU INT3 for EPWM1_INT: IER |= (M_INT2 | M_INT3); // Initialize scia: /*#if PRODUCT_TYPE_ID==PRODUCT_TYPE_DRIVER_HZ gpioReg.init_HC(&gpioReg); #else*/ gpioReg.init(&gpioReg); //#endif sciCom1.LspClk = ((Uint32)SYSTEM_FREQUENCY*1000000/4); sciCom1.ComNo = SCI_COM1;//usb sciCom1.BaudRate = 9600; sciCom1.init(&sciCom1); // sciCom2.LspClk = ((Uint32)SYSTEM_FREQUENCY*1000000/4); // sciCom2.ComNo = SCI_COM2;//485 // sciCom2.BaudRate = 19200; // sciCom2.init(&sciCom2); fun_errorInit(); fun_ioSignalInit(); fun_dbCtrlInit(); fun_adInit(); fun_eepromInit(); fun_saveRomInit(); ////////////////// fun_machineLockInit(); fun_intfDataInit(); fun_internParaInit(); fun_timerInit(); // fun_masterEncInit(); fun_fanCtrl_init(); fun_sysCtrlInit(); fun_motorDriveInit(); fun_MODBUS_Init(&sciCom1); fun_overLoadInit(); fun_mtAngleOriginInit(); fun_mtoffsetTestInit(); // fun_mtoffsetTestHallInit(); fun_mtAngleInit(); fun_mtCtrlModInit(); fun_dataLogInit(); fun_trqSeltInit(); fun_spdSeltInit(); fun_posSeltInit(); fun_udcSeltInit(); fun_posGenInit(); fun_speedInit(); // fun_appCtrlEMPInit(); fun_mtCtrl_fsm_Init(); fun_appCtrlInit(); fun_runLedInit(); // fun_mtDriveOnInit(); fun_chargCtrlInit(); // fun_appCompInit(); // fun_appDensityInit(); fun_tmpMd_Init(); // fun_appTsn_init(); fun_ad_offsetCheck(); // encoder_para_init(); fun_appCtrl_fsm_Init(); fun_appCtrl_fsm_para_Init(); DI_init(); DI_para_init(); DO_led_init(); DO_init(); encoder_para_init(); //必须在fun_mtEnc_init()之后 error_init_withoutEeprom(); error_init_withEeprom(); production_init(); weftSens_init(); weftSens_para_init(); fun_phaseLackInit(); // fun_testParInit(); fun_fuzzyPIDInit(); // EvaRegs.T1CON.bit.TENABLE = 1; // Enable global Interrupts and higher priority real-time debug events: EnableDog(); EINT; // Enable Global interrupt INTM ERTM; // Enable Global realtime interrupt DBGM } #endif 为什么会触发PdpintISR()这个中断函数
最新发布
07-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值