关于 DSP 2812 外部中断 XINT1 使用问题 15
我在单位用DSP使用外部中断Xint1的时候,无法进入中断,示波器测量有中断产生,我们使用点评的变换来作为触发的,在设置各种寄存器时能之后,还有设置外部中断寄存器用上升沿...
我在单位用DSP 使用外部中断 Xint1 的时候, 无法进入中断,示波器测量有中断产生,我们使用点评的变换来作为触发的, 在设置各种寄存器时能之后,还有设置外部中断寄存器用上升沿还是下降沿触发, 反正该设置的我都找了资料,百度后,还是不行,有谁能给个简单示例? 简约的代码?谢谢了。
展开
1个回答
展开全部
这是 DSP28335的例程,程序目的是通过按不同的按键,通过中断改变LED的闪动方式
,你可以对比一下。 (DSP2812和 DSP28335是差不多的)
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#define LED1_ON GpioDataRegs.GPASET.bit.GPIO0=1
#define LED1_OFF GpioDataRegs.GPACLEAR.bit.GPIO0=1
#define LED2_ON GpioDataRegs.GPASET.bit.GPIO1=1
#define LED2_OFF GpioDataRegs.GPACLEAR.bit.GPIO1=1
#define LED3_ON GpioDataRegs.GPASET.bit.GPIO2=1
#define LED3_OFF GpioDataRegs.GPACLEAR.bit.GPIO2=1
#define LED4_ON GpioDataRegs.GPASET.bit.GPIO3=1
#define LED4_OFF GpioDataRegs.GPACLEAR.bit.GPIO3=1
#define LED5_ON GpioDataRegs.GPASET.bit.GPIO4=1
#define LED5_OFF GpioDataRegs.GPACLEAR.bit.GPIO4=1
#define LED6_ON GpioDataRegs.GPASET.bit.GPIO5=1
#define LED6_OFF GpioDataRegs.GPACLEAR.bit.GPIO5=1
#define LED7_ON GpioDataRegs.GPBSET.bit.GPIO51=1
#define LED7_OFF GpioDataRegs.GPBCLEAR.bit.GPIO51=1
#define LED8_ON GpioDataRegs.GPBSET.bit.GPIO50=1
#define LED8_OFF GpioDataRegs.GPBCLEAR.bit.GPIO50=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_SysCtrl.c file.
InitSysCtrl();
// Step 2. Initalize GPIO:
// This example function is found in the DSP2833x_Gpio.c 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_PieCtrl.c 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_DefaultIsr.c.
// This function is found in DSP2833x_PieVect.c.
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
PieVectTable.XINT3 = &ISRExint3;
PieVectTable.XINT4 = &ISRExint4;
PieVectTable.XINT5 = &ISRExint5;
PieVectTable.XINT6 = &ISRExint6;
EDIS; // This is needed to disable write to EALLOW protected registers
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block
PieCtrlRegs.PIEIER12.bit.INTx1= 1;
PieCtrlRegs.PIEIER12.bit.INTx2= 1;
PieCtrlRegs.PIEIER12.bit.INTx3= 1;
PieCtrlRegs.PIEIER12.bit.INTx4= 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)
{
PieCtrlRegs.PIEACK.all = PIEACK_GROUP12;
sign=3;
}
interrupt void ISRExint4(void)
{
PieCtrlRegs.PIEACK.all = PIEACK_GROUP12;
sign=4;
}
interrupt void ISRExint5(void)
{
PieCtrlRegs.PIEACK.all = PIEACK_GROUP12;
sign=5;
}
interrupt void ISRExint6(void)
{
PieCtrlRegs.PIEACK.all = PIEACK_GROUP12;
sign=6;
}
void configtestled(void)
{
EALLOW;
GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0; // GPIO0 = GPIO0
GpioCtrlRegs.GPADIR.bit.GPIO0 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 0; // GPIO1 = GPIO1
GpioCtrlRegs.GPADIR.bit.GPIO1 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 0; // GPIO2 = GPIO2
GpioCtrlRegs.GPADIR.bit.GPIO2 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 0; // GPIO3 = GPIO3
GpioCtrlRegs.GPADIR.bit.GPIO3 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO4 = 0; // GPIO4 = GPIO4
GpioCtrlRegs.GPADIR.bit.GPIO4 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO5 = 0; // GPIO5 = GPIO5
GpioCtrlRegs.GPADIR.bit.GPIO5 = 1;
GpioCtrlRegs.GPBMUX2.bit.GPIO51 = 0; // GPIO51 = GPIO51
GpioCtrlRegs.GPBDIR.bit.GPIO51 = 1;
GpioCtrlRegs.GPBPUD.bit.GPIO51=0;
GpioCtrlRegs.GPBMUX2.bit.GPIO50 = 0; // GPIO50 = GPIO50
GpioCtrlRegs.GPBDIR.bit.GPIO50 = 1;
GpioCtrlRegs.GPBPUD.bit.GPIO50=0;
EDIS;
}
//===========================================================================
// No more.
//===========================================================================
,你可以对比一下。 (DSP2812和 DSP28335是差不多的)
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#define LED1_ON GpioDataRegs.GPASET.bit.GPIO0=1
#define LED1_OFF GpioDataRegs.GPACLEAR.bit.GPIO0=1
#define LED2_ON GpioDataRegs.GPASET.bit.GPIO1=1
#define LED2_OFF GpioDataRegs.GPACLEAR.bit.GPIO1=1
#define LED3_ON GpioDataRegs.GPASET.bit.GPIO2=1
#define LED3_OFF GpioDataRegs.GPACLEAR.bit.GPIO2=1
#define LED4_ON GpioDataRegs.GPASET.bit.GPIO3=1
#define LED4_OFF GpioDataRegs.GPACLEAR.bit.GPIO3=1
#define LED5_ON GpioDataRegs.GPASET.bit.GPIO4=1
#define LED5_OFF GpioDataRegs.GPACLEAR.bit.GPIO4=1
#define LED6_ON GpioDataRegs.GPASET.bit.GPIO5=1
#define LED6_OFF GpioDataRegs.GPACLEAR.bit.GPIO5=1
#define LED7_ON GpioDataRegs.GPBSET.bit.GPIO51=1
#define LED7_OFF GpioDataRegs.GPBCLEAR.bit.GPIO51=1
#define LED8_ON GpioDataRegs.GPBSET.bit.GPIO50=1
#define LED8_OFF GpioDataRegs.GPBCLEAR.bit.GPIO50=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_SysCtrl.c file.
InitSysCtrl();
// Step 2. Initalize GPIO:
// This example function is found in the DSP2833x_Gpio.c 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_PieCtrl.c 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_DefaultIsr.c.
// This function is found in DSP2833x_PieVect.c.
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
PieVectTable.XINT3 = &ISRExint3;
PieVectTable.XINT4 = &ISRExint4;
PieVectTable.XINT5 = &ISRExint5;
PieVectTable.XINT6 = &ISRExint6;
EDIS; // This is needed to disable write to EALLOW protected registers
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block
PieCtrlRegs.PIEIER12.bit.INTx1= 1;
PieCtrlRegs.PIEIER12.bit.INTx2= 1;
PieCtrlRegs.PIEIER12.bit.INTx3= 1;
PieCtrlRegs.PIEIER12.bit.INTx4= 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)
{
PieCtrlRegs.PIEACK.all = PIEACK_GROUP12;
sign=3;
}
interrupt void ISRExint4(void)
{
PieCtrlRegs.PIEACK.all = PIEACK_GROUP12;
sign=4;
}
interrupt void ISRExint5(void)
{
PieCtrlRegs.PIEACK.all = PIEACK_GROUP12;
sign=5;
}
interrupt void ISRExint6(void)
{
PieCtrlRegs.PIEACK.all = PIEACK_GROUP12;
sign=6;
}
void configtestled(void)
{
EALLOW;
GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0; // GPIO0 = GPIO0
GpioCtrlRegs.GPADIR.bit.GPIO0 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 0; // GPIO1 = GPIO1
GpioCtrlRegs.GPADIR.bit.GPIO1 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 0; // GPIO2 = GPIO2
GpioCtrlRegs.GPADIR.bit.GPIO2 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 0; // GPIO3 = GPIO3
GpioCtrlRegs.GPADIR.bit.GPIO3 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO4 = 0; // GPIO4 = GPIO4
GpioCtrlRegs.GPADIR.bit.GPIO4 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO5 = 0; // GPIO5 = GPIO5
GpioCtrlRegs.GPADIR.bit.GPIO5 = 1;
GpioCtrlRegs.GPBMUX2.bit.GPIO51 = 0; // GPIO51 = GPIO51
GpioCtrlRegs.GPBDIR.bit.GPIO51 = 1;
GpioCtrlRegs.GPBPUD.bit.GPIO51=0;
GpioCtrlRegs.GPBMUX2.bit.GPIO50 = 0; // GPIO50 = GPIO50
GpioCtrlRegs.GPBDIR.bit.GPIO50 = 1;
GpioCtrlRegs.GPBPUD.bit.GPIO50=0;
EDIS;
}
//===========================================================================
// No more.
//===========================================================================
参考资料: 研旭嵌入式 例程
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
光派通信
2024-09-03 广告
2024-09-03 广告
对光传输设备进行调试和维护,需要掌握以下关键点:1. **熟悉设备性能**:深入了解OTN/DWDM等光传输产品的性能特点,确保能够熟练使用设备。2. **按规范操作**:依据产品说明书和维护手册进行调试和维护,确保操作步骤正确无误。3. ...
点击进入详情页
本回答由光派通信提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询