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
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;
delay(30);
Led1=1;
delay(30);
Led2=0;
delay(30);
Led3=1;
delay(30);
Led4=0;
while(1)
{
delay(3000);
Led0=~Led0;
delay(30);
Led1=~Led1;
delay(30);
Led2=~Led2;
delay(30);
Led3=~Led3;
delay(30);
Led4=~Led4;
}
}
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;
EDIS;
}
2015年11月11日 10点11分