当然可以使能,每个EPWM都要自己独立的中断向量,只要满足中断条件,相应的EPWM中断就会发生;
但是需要注意的是,中断有优先级,虽然可以同时使能两路中断,但是却不能同时执行两路中断,当两路中断同时发生时,优先级高的那个EPWM先进入中断处理,处理完之后才能处理另一个EPWM的中断。
中断服务程序,处理器处理“急件”,可理解为是一种服务,是通过执行事先编好的某个特定的程序来完成的,这种处理“急件”的程序被称为——中断服务程序。
_朊坷_/O设备相关的进程都有一个靠近内存底部的地址,称作中断向量。_ㄖ卸戏癯绦虻娜肟诘刂贰
当中央处理器正在处理内部数据时,外界发生了紧急情况,要求CPU暂停当前的工作转去处理这个紧急事件。处理完毕后,再回到原来被中断的地址,继续原来的工作,这样的过程称为中断。实现这一功能的部件称为中断系统,申请CPU中断的请求源称为中断源,单片机的中断系统一般允许多个中断源,当多个中断源同时向CPU请求中断时,就存在一个中断优先权的问题。通常根据中断源的优先级别,优先处理最紧急事件的中断请求源,即最先响应级别最高的中断请求。
这是 DSP28335的例程,程序目的是通过按不同的按键,通过中断改变LED的闪动方式
,你可以对比一下。 (DSP2812和 DSP28335是差不多的)
#include "DSP2833x_Deviceh" // DSP2833x Headerfile Include File#include "DSP2833x_Examplesh" // DSP2833x Examples Include File
#define LED1_ON GpioDataRegsGPASETbitGPIO0=1
#define LED1_OFF GpioDataRegsGPACLEARbitGPIO0=1
#define LED2_ON GpioDataRegsGPASETbitGPIO1=1
#define LED2_OFF GpioDataRegsGPACLEARbitGPIO1=1
#define LED3_ON GpioDataRegsGPASETbitGPIO2=1
#define LED3_OFF GpioDataRegsGPACLEARbitGPIO2=1
#define LED4_ON GpioDataRegsGPASETbitGPIO3=1
#define LED4_OFF GpioDataRegsGPACLEARbitGPIO3=1
#define LED5_ON GpioDataRegsGPASETbitGPIO4=1
#define LED5_OFF GpioDataRegsGPACLEARbitGPIO4=1
#define LED6_ON GpioDataRegsGPASETbitGPIO5=1
#define LED6_OFF GpioDataRegsGPACLEARbitGPIO5=1
#define LED7_ON GpioDataRegsGPBSETbitGPIO51=1
#define LED7_OFF GpioDataRegsGPBCLEARbitGPIO51=1
#define LED8_ON GpioDataRegsGPBSETbitGPIO50=1
#define LED8_OFF GpioDataRegsGPBCLEARbitGPIO50=1
interrupt void ISRExint3(void);
interrupt void ISRExint4(void);
interrupt void ISRExint5(void);
interrupt void ISRExint6(void);
void configtestled(void);
Uint16 sign ;
void main(void)
{
// Step 1 Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2833x_SysCtrlc file
InitSysCtrl();
// Step 2 Initalize GPIO:
// This example function is found in the DSP2833x_Gpioc file and
// illustrates how to set the GPIO to it's default state
// InitGpio(); // Skipped for this example
InitXintf16Gpio(); //zq
// Step 3 Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
DINT;
// Initialize the PIE control registers to their default state
// The default state is all PIE interrupts disabled and flags
// are cleared
// This function is found in the DSP2833x_PieCtrlc file
InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR)
// This will populate the entire table, even if the interrupt
// is not used in this example This is useful for debug purposes
// The shell ISR routines are found in DSP2833x_DefaultIsrc
// This function is found in DSP2833x_PieVectc
InitPieVectTable();
// Interrupts that are used in this example are re-mapped to// ISR functions found within this file
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTableXINT3 = &ISRExint3;
PieVectTableXINT4 = &ISRExint4;
PieVectTableXINT5 = &ISRExint5;
PieVectTableXINT6 = &ISRExint6;
EDIS; // This is needed to disable write to EALLOW protected registers
PieCtrlRegsPIECTRLbitENPIE = 1; // Enable the PIE block
PieCtrlRegsPIEIER12bitINTx1= 1;
PieCtrlRegsPIEIER12bitINTx2= 1;
PieCtrlRegsPIEIER12bitINTx3= 1;
PieCtrlRegsPIEIER12bitINTx4= 1;
IER |= M_INT12; // Enable CPU int1
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
configtestled();
sign = 0;
while(1)
{
if(sign==0)
{ LED1_OFF;
LED2_OFF;
LED3_OFF;
LED4_OFF;
LED5_OFF;
LED6_OFF;
LED7_OFF;
LED8_OFF;
DELAY_US(50000);
LED1_ON;
DELAY_US(50000);
LED2_ON;
DELAY_US(50000);
LED3_ON;
DELAY_US(50000);
LED4_ON;
DELAY_US(50000);
LED5_ON;
DELAY_US(50000);
LED6_ON;
DELAY_US(50000);
LED7_ON;
DELAY_US(50000);
LED8_ON;
DELAY_US(50000); //NO XINT
}
if(sign==3)
{
LED1_OFF;
LED2_OFF;
LED3_OFF;
LED4_OFF;
LED5_OFF;
LED6_OFF;
LED7_OFF;
LED8_OFF;
DELAY_US(50000);
LED1_ON;
LED2_ON;
DELAY_US(50000);
LED3_ON;
LED4_ON;
DELAY_US(50000);
LED5_ON;
LED6_ON;
DELAY_US(50000);
LED7_ON;
LED8_ON;
DELAY_US(50000); // XINT3 COME
}
if(sign==4)
{ LED1_ON;
LED2_ON;
LED3_ON;
LED4_ON;
LED5_ON;
LED6_ON;
LED7_ON;
LED8_ON;
DELAY_US(50000);
LED1_OFF;
DELAY_US(50000);
LED2_OFF;
DELAY_US(50000);
LED3_OFF;
DELAY_US(50000);
LED4_OFF;
DELAY_US(50000);
LED5_OFF;
DELAY_US(50000);
LED6_OFF;
DELAY_US(50000);
LED7_OFF;
DELAY_US(50000);
LED8_OFF;
DELAY_US(50000); // XINT4 COME
}
if(sign==5)
{LED1_ON;
LED2_ON;
LED3_ON;
LED4_ON;
LED5_ON;
LED6_ON;
LED7_ON;
LED8_ON;
DELAY_US(50000);
LED1_OFF;
LED2_OFF;
DELAY_US(50000);
LED3_OFF;
LED4_OFF;
LED1_ON;
LED2_ON;
DELAY_US(50000);
LED5_OFF;
LED6_OFF;
LED3_ON;
LED4_ON;
DELAY_US(50000);
LED7_OFF;
LED8_OFF;
LED5_ON;
LED6_ON;
DELAY_US(50000); // XINT5 COME
}
if(sign==6)
{LED1_OFF;
LED2_ON;
LED3_OFF;
LED4_ON;
LED5_OFF;
LED6_ON;
LED7_OFF;
LED8_ON;
DELAY_US(50000);
LED1_ON;
LED2_OFF;
LED3_ON;
LED4_OFF;
LED5_ON;
LED6_OFF;
LED7_ON;
LED8_OFF;
DELAY_US(50000); // XINT5 COME
}
}
}
interrupt void ISRExint3(void)
{
PieCtrlRegsPIEACKall = PIEACK_GROUP12;
sign=3;
}
interrupt void ISRExint4(void)
{
PieCtrlRegsPIEACKall = PIEACK_GROUP12;
sign=4;
}
interrupt void ISRExint5(void)
{
PieCtrlRegsPIEACKall = PIEACK_GROUP12;
sign=5;
}
interrupt void ISRExint6(void)
{
PieCtrlRegsPIEACKall = PIEACK_GROUP12;
sign=6;
}
void configtestled(void)
{
EALLOW;
GpioCtrlRegsGPAMUX1bitGPIO0 = 0; // GPIO0 = GPIO0
GpioCtrlRegsGPADIRbitGPIO0 = 1;
GpioCtrlRegsGPAMUX1bitGPIO1 = 0; // GPIO1 = GPIO1
GpioCtrlRegsGPADIRbitGPIO1 = 1;
GpioCtrlRegsGPAMUX1bitGPIO2 = 0; // GPIO2 = GPIO2
GpioCtrlRegsGPADIRbitGPIO2 = 1;
GpioCtrlRegsGPAMUX1bitGPIO3 = 0; // GPIO3 = GPIO3
GpioCtrlRegsGPADIRbitGPIO3 = 1;
GpioCtrlRegsGPAMUX1bitGPIO4 = 0; // GPIO4 = GPIO4
GpioCtrlRegsGPADIRbitGPIO4 = 1;
GpioCtrlRegsGPAMUX1bitGPIO5 = 0; // GPIO5 = GPIO5
GpioCtrlRegsGPADIRbitGPIO5 = 1;
GpioCtrlRegsGPBMUX2bitGPIO51 = 0; // GPIO51 = GPIO51
GpioCtrlRegsGPBDIRbitGPIO51 = 1;
GpioCtrlRegsGPBPUDbitGPIO51=0;
GpioCtrlRegsGPBMUX2bitGPIO50 = 0; // GPIO50 = GPIO50
GpioCtrlRegsGPBDIRbitGPIO50 = 1;
GpioCtrlRegsGPBPUDbitGPIO50=0;
EDIS;
}
//===========================================================================
// No more
//===========================================================================
以上就是关于dsp28335 能够同时使能两路epwm中断么全部的内容,包括:dsp28335 能够同时使能两路epwm中断么、按键长按三秒启动中断程序。、关于 DSP 2812 外部中断 XINT1 使用问题等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)