网站公告列表

  没有公告

加入收藏
设为首页
联系站长
您现在的位置: 61IC中国电子在线 >> DSP >> 代码示例 >> TI DSP代码示例 >> C2000 >> 文章正文
  TI DSP2812的GPIO的应用: 跑马灯程序         ★★★ 【字体:
TI DSP2812的GPIO的应用: 跑马灯程序
作者:61IC    文章来源:本站原创    点击数:    更新时间:2007-1-17    

详细说明:这是一个TI DSP2812GPIO的应用: 跑马灯程序,可以让8Led,每隔一秒钟依序轮流闪烁,附录了完整的程序批注

//###########################################################################
//
// FILE:  Example_281xGpio_Led.c  Edited by  Steven-Tsao 
//
// TITLE: DSP281x GPIO LED Test   
//
//
//        This program requires the DSP281x V1.00 header files. 
//        As supplied, this project is configured for "boot to H0" operation.
//
//        To work properly this test requires hardware configuration described
//        below.
//
//###########################################################################

//###########################################################################

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


// Prototype statements for functions found within this file.

Uint16 j=0x0001;
short i ;
 
void Gpio_select(void);
void delay_loop(Uint16 loop_time);

void main(void)
{

// Step 1. Initialize System Control registers, PLL, WatchDog,
// peripheral Clocks to default state:
// This function is found in the DSP281x_SysCtrl.c file.
   InitSysCtrl();

// 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 

// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
   DINT;

// Initialize 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

// Step 5. User specific code
 Gpio_select();
 
// *******************************************//
// ************    *************//

GpioDataRegs.GPACLEAR.all=0xFFFF; // All GpioAx to  OFF 
GpioDataRegs.GPADAT.all=j;    // First led light ON
delay_loop(1000);         // Delay 1[s]

while(1)             //
{
 
 for(i=1;i<8;i++)        // The second led to eighth one lights by turns
 { 
  j=0x0001<<(8*i);
  GpioDataRegs.GPADAT.all=j;
  delay_loop(1000);       // // Delay 1[s]
 }
 
 for(i=1;i<8;i++)
 { 
  j=0x1000>>(8*i);       // The seventh led to first one lights by turns
  GpioDataRegs.GPADAT.all=j;
  delay_loop(1000);       // Delay 1[s]
 }

}
  

}


void Gpio_select(void)
{
     EALLOW;
  
    GpioMuxRegs.GPAMUX.all = 0x0000;   // Configure MUXs as digital I/Os
                                          
    GpioMuxRegs.GPADIR.all = 0xFFFF;   // GPIO PORTs  as output
 
    GpioMuxRegs.GPAQUAL.all = 0x0000;  // Set GPIO input qualifier values
 
    EDIS;    
}    

//  **********************************************  //
// Delay time function : set i[ms] with delay time function
//  **********************************************  //

void delay_loop(Uint16 loop_time)
{
    short      i;
   
    for (i = 0; i < loop_time; i++) {asm(" RPT #100000 ||NOP ");}
}

 

//===========================================================================
// No more.
//===========================================================================

               欢迎点击进入:TI德州中文网   (国内唯一针对TI应用的中文技术网站)    文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    TI DSP2812系列开发套件功能…
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    站长:61IC 湘ICP备05002478号