wuyouwuyou

开发板引脚测试

0
阅读(1827)

此模块由数码管和四个锁存器组成。数码管为共阴极型的。数据由2812模块的低八位输入,锁存器的控制信号由2812模块输出,但经由CPLD模块译码后再控制对应的八个

#include "include/DSP281x_Examples.h"   // DSP281x Examples Include File

// Prototype statements for functions found within this file.

void delay_loop(void);

void Gpio_select(void);

// Global variable for this example

short codetab[17]=

{0x4020,0x6cc0,0x5800,0x4840,0x6440,0xC040,0xC000,0x4cc0,

0x4000,0x4040,0x4400,0xE000,0xD080,0xE800,0xD000,0xD400,0xffff};

 

main()

{

   short i;

// Step 1. Initialize System Control:

// PLL, WatchDog, enable Peripheral Clocks

// This example function is found in the DSP281x_SysCtrl.c file.

   InitSysCtrl();

     

// Specific clock setting for this example:     

   EALLOW;

   EDIS;

// Step 2. Initalize GPIO:

// This example function is found in the DSP281x_Gpio.c file and

// illustrates how to set the GPIO to it's default state.

// InitGpio();  // Skipped for this example

// For this example use the following configuration:

   Gpio_select();

// 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 DSP281x_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 DSP281x_DefaultIsr.c.

// This function is found in DSP281x_PieVect.c.

   InitPieVectTable();

// Step 4. Initialize all the Device Peripherals:

// This function is found in DSP281x_InitPeripherals.c

// InitPeripherals(); // Not required for this example

   InitXintf();  // For this example, init the Xintf

// Step 5. User specific code, enable interrupts:

   GpioDataRegs.GPADAT.all=0;

   Reg01=0x00;

   GpioDataRegs.GPADAT.all=0;

   Reg02=0x00;

   GpioDataRegs.GPADAT.all=0;

   Reg03=0x00;

   GpioDataRegs.GPADAT.all=0;

   Reg04=0x00;

   while(1)

   { 

     for(i=0;i<17;i++)

     {

          GpioDataRegs.GPADAT.all    =~codetab[i];

          Reg01=0x00;

          delay_loop();

     }

     for(i=0;i<17;i++)

     {

          GpioDataRegs.GPADAT.all    =~codetab[i];

          Reg02=0x00;

          delay_loop();

     }

     for(i=0;i<17;i++)

     {

          GpioDataRegs.GPADAT.all    =~codetab[i];

          Reg03=0x00;

          delay_loop();

     }

     for(i=0;i<17;i++)

     {

          GpioDataRegs.GPADAT.all    =~codetab[i];

          Reg04=0x00;

          delay_loop();

     }

   }

}

 

void delay_loop()

{

    short      i,j;

    for (i = 0; i < 32767; i++)

    {for (j = 0; j < 10; j++);}

}