level 1
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#define Led0 GpioDataRegs.GPADAT.bit.GPIO0
#define Led1 GpioDataRegs.GPADAT.bit.GPIO1
#define Led2 GpioDataRegs.GPADAT.bit.GPIO2
#define Led3 GpioDataRegs.GPADAT.bit.GPIO3
#define Led4 GpioDataRegs.GPADAT.bit.GPIO4
#define con0 GpioDataRegs.GPADAT.bit.GPIO21
#define con1 GpioDataRegs.GPADAT.bit.GPIO20
#define con2 GpioDataRegs.GPADAT.bit.GPIO27
#define key0 GpioDataRegs.GPADAT.bit.GPIO23
#define key1 GpioDataRegs.GPADAT.bit.GPIO24
#define key2 GpioDataRegs.GPADAT.bit.GPIO25
#define key3 GpioDataRegs.GPADAT.bit.GPIO26
void configure();
void delay(int);
void main()
{
// 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();
configure();
Led0=0;
Led1=1;
Led2=0;
Led3=1;
Led4=0;
con0=1;
con1=1;
con2=1;
while(1)
{
if(key0==0)
Led0=~Led0;
else if(key1==0)
Led1=~Led1;
else if(key2==0)
Led2=~Led2;
else if(key3==0)
Led3=~Led3;
Led4=~Led4;
delay(3000);
}
}
void delay(int k)
{
int i;
int j;
for(i=k;i>=0;i--)
for(j=0;j<1000;j++);
}
void configure()
{
EALLOW;
GpioCtrlRegs.GPAMUX1.bit.GPIO0=0;
GpioCtrlRegs.GPADIR.bit.GPIO0=1;
GpioCtrlRegs.GPAMUX1.bit.GPIO1=0;
GpioCtrlRegs.GPADIR.bit.GPIO1=1;
GpioCtrlRegs.GPAMUX1.bit.GPIO2=0;
GpioCtrlRegs.GPADIR.bit.GPIO2=1;
GpioCtrlRegs.GPAMUX1.bit.GPIO3=0;
GpioCtrlRegs.GPADIR.bit.GPIO3=1;
GpioCtrlRegs.GPAMUX1.bit.GPIO4=0;
GpioCtrlRegs.GPADIR.bit.GPIO4=1;
GpioCtrlRegs.GPAMUX2.bit.GPIO21=0;
GpioCtrlRegs.GPADIR.bit.GPIO21=1;
GpioCtrlRegs.GPAMUX2.bit.GPIO20=0;
GpioCtrlRegs.GPADIR.bit.GPIO20=1;
GpioCtrlRegs.GPAMUX2.bit.GPIO27=0;
GpioCtrlRegs.GPADIR.bit.GPIO27=1;
GpioCtrlRegs.GPAMUX2.bit.GPIO23=0;
GpioCtrlRegs.GPADIR.bit.GPIO23=0;
GpioCtrlRegs.GPAMUX2.bit.GPIO24=0;
GpioCtrlRegs.GPADIR.bit.GPIO24=0;
GpioCtrlRegs.GPAMUX2.bit.GPIO25=0;
GpioCtrlRegs.GPADIR.bit.GPIO25=0;
GpioCtrlRegs.GPAMUX2.bit.GPIO26=0;
GpioCtrlRegs.GPADIR.bit.GPIO26=0;
EDIS;
}
2015年11月11日 10点11分
2
好久没上贴吧了,谢谢你的回答
![[哈哈]](/static/emoticons/u54c8u54c8.png)
!
2017年01月06日 07点01分