DSP TMS320F28335实现按键控制LED
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include "DSP2833x_Device.h"
#include "DSP2833x_Examples.h"
interrupt void Xint3_isr(void);
interrupt void Xint4_isr(void); i
nterrupt void Xint5_isr(void);
void main()
{
InitSysCtrl();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.XINT3 = &Xint3_isr;
PieVectTable.XINT4 = &Xint4_isr;
PieVectTable.XINT5 = &Xint5_isr;
EDIS;
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
PieCtrlRegs.PIEIER12.bit.INTx1 = 1;
PieCtrlRegs.PIEIER12.bit.INTx2 = 1;
PieCtrlRegs.PIEIER12.bit.INTx3 = 1;
IER |= M_INT12;
EINT;
EALLOW;
GpioCtrlRegs.GPBPUD.bit.GPIO50 = 0;
GpioDataRegs.GPBCLEAR.bit.GPIO50 = 1;
GpioCtrlRegs.GPBMUX2.bit.GPIO50 = 0;
GpioCtrlRegs.GPBDIR.bit.GPIO50 = 1;
GpioCtrlRegs.GPBPUD.bit.GPIO53 = 0;
GpioCtrlRegs.GPBMUX2.bit.GPIO53 = 0;
GpioCtrlRegs.GPBDIR.bit.GPIO53 = 0;
GpioCtrlRegs.GPBPUD.bit.GPIO52 = 0;
GpioCtrlRegs.GPBMUX2.bit.GPIO52 = 0;
GpioCtrlRegs.GPBDIR.bit.GPIO52 = 0;
GpioCtrlRegs.GPBPUD.bit.GPIO51 = 0;
GpioCtrlRegs.GPBMUX2.bit.GPIO51 = 0;
GpioCtrlRegs.GPBDIR.bit.GPIO51 = 0;
GpioCtrlRegs.GPAPUD.bit.GPIO0 = 0;
GpioDataRegs.GPASET.bit.GPIO0 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO0 = 1;
GpioCtrlRegs.GPAPUD.bit.GPIO1 = 0;
GpioDataRegs.GPASET.bit.GPIO1 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO1 = 1;
GpioCtrlRegs.GPAPUD.bit.GPIO2 = 0;
GpioDataRegs.GPASET.bit.GPIO2 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO2 = 1;
EDIS;
EALLOW;
GpioIntRegs.GPIOXINT3SEL.bit.GPIOSEL = 53;
GpioIntRegs.GPIOXINT4SEL.bit.GPIOSEL = 52;
GpioIntRegs.GPIOXINT5SEL.bit.GPIOSEL = 51;
XIntruptRegs.XINT3CR.bit.POLARITY = 0;
XIntruptRegs.XINT4CR.bit.POLARITY = 0;
XIntruptRegs.XINT5CR.bit.POLARITY = 0;
XIntruptRegs.XINT3CR.bit.ENABLE = 1;
XIntruptRegs.XINT4CR.bit.ENABLE = 1;
XIntruptRegs.XINT5CR.bit.ENABLE = 1;
EDIS;
for(;;);
}
interrupt void Xint3_isr(void)
{
GpioDataRegs.GPATOGGLE.bit.GPIO0 = 1;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP12;
}
interrupt void Xint4_isr(void)
{
GpioDataRegs.GPATOGGLE.bit.GPIO1 = 1;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP12;
}
interrupt void Xint5_isr(void)
{
GpioDataRegs.GPATOGGLE.bit.GPIO2 = 1;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP12;
}