网站公告列表

  没有公告

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

//
//      TMDX ALPHA RELEASE
//      Intended for product evaluation purposes
//
//###########################################################################
//
// FILE: Example_28xCpuTimer.c
//
// TITLE: DSP28 Device Getting Started Program.
//
// ASSUMPTIONS:
//
//          This program requires the DSP28 header files.  To compile the
//          program as is, it should reside in the DSP28/examples/cpu_timer
//          sub-directory.
//
//          As supplied, this project is configured for "boot to H0" operation. 
//
// DESCRIPTION:
//
//          This example configures CPU Timer0 and increments
//          a counter each time the timer asserts an interrupt.
//
//          The DSP28 headerfiles are required to build this example.
//      
//          Watch Variables:
//                 CpuTimer0.InterruptCount
//
//###########################################################################
//
//  Ver | dd mmm yyyy | Who  | Description of changes
// =====|=============|======|===============================================
//  0.55| 06 May 2002 | S.S. | EzDSP Alpha Release
//  0.56| 20 May 2002 | L.H. | Peripheral frame 1 & 2 names were swapped
//  0.57| 27 May 2002 | L.H. | No change
//  0.58| 18 Jun 2002 | L.H. | Changed example to use CpuTimer0 instead of
//      |             |      | CpuTimer2.  CpuTimer1 and CpuTimer2 are reserved
//      |             |      | for DSP BIOS and other RTOS applications
//###########################################################################

// Step 0.  Include required header files
         // DSP28_Device.h: device specific definitions #include statements for
         // all of the peripheral .h definition files.
         // DSP28_Example.h is specific for the given example. 

#include "DSP28_Device.h"


// Prototype statements for functions found within this file.
interrupt void cpu_timer0_isr(void);

void main(void)
{

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

// Step 2. Select GPIO for the device or for the specific application:
    // This function is found in the DSP28_Gpio.c file.
    // InitGpio();  // Not required for this example

// Step 3. Initialize PIE vector table:
    // The PIE vector table is initialized with pointers to shell Interrupt
    // Service Routines (ISR).  The shell routines are found in DSP28_DefaultIsr.c.
    // Insert user specific ISR code in the appropriate shell ISR routine in
    // the DSP28_DefaultIsr.c file.

    // Disable and clear all CPU interrupts:
 DINT;
 IER = 0x0000;
 IFR = 0x0000;

    // Initialize Pie Control Registers To Default State:
    // This function is found in the DSP28_PieCtrl.c file.
 InitPieCtrl();

    // Initialize the PIE Vector Table To a Known State:
    // This function is found in DSP28_PieVect.c.
    // This function populates the PIE vector table with pointers
    // to the shell ISR functions found in DSP28_DefaultIsr.c.
 InitPieVectTable(); 
 
// Step 4. Initialize all the Device Peripherals to a known state:
    // This function is found in DSP28_InitPeripherals.c
    // InitPeripherals();  // For this example just init the CPU Timers
    InitCpuTimers();

// Step 5. User specific functions, Reassign vectors (optional), Enable Interrupts:
 
    // Initialize CPU Timer 0:
    //  > Set Up For 1 Second Interrupt Period
    //  > Point To "cpu_timer0_isr" function

    // Reassign CPU-Timer0 ISR.
    // Reassign the PIE vector for TINT0 to point to a different ISR then
    // the shell routine found in DSP28_DefaultIsr.c.
    // This is done if the user does not want to use the shell ISR routine
    // but instead wants to use their own ISR.  This step is optional:
 
 EALLOW; // This is needed to write to EALLOW protected registers
 PieVectTable.TINT0 = &cpu_timer0_isr;
 EDIS;       // This is needed to disable write to EALLOW protected registers
   
    // Include application specific functions. This is for this example:
 
    // Configure CPU-Timer 0 to interrupt every second:
 ConfigCpuTimer(&CpuTimer0, 100, 1000000); // 100MHz CPU Freq, 1 second Period (in uSeconds)
  StartCpuTimer0();

    // Enable CPU INT1 which is connected to CPU-Timer 0:
 IER |= M_INT1;
 
    // Enable TINT0 in the PIE: Group 1 interrupt 7
 PieCtrlRegs.PIEIER1.bit.INTx7 = 1;

    // Enable global Interrupts and higher priority real-time debug events:
 
 EINT;   // Enable Global interrupt INTM
 ERTM;   // Enable Global realtime interrupt DBGM

// Step 6. IDLE loop. Just sit and loop forever (optional): 
 for(;;);

}  


// Step 7. Insert all local Interrupt Service Routines (ISRs) and functions here: 
 // If local ISRs are used, reassign vector addresses in vector table as
      // shown in Step 5

interrupt void cpu_timer0_isr(void)
{
 CpuTimer0.InterruptCount++;
 
 // Acknowledge this interrupt to recieve more interrupts from group 1
 PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; 
}

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

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

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    TMS320F2812的SPWM原程序
    基于LabVIEW和TMS320F2812的…
    TMS320F2812的CAN调试成功经…
    基于TMS320F2812和μC/OS II…
    TMS320F2812 全局汇编函数
    TMS320F2812 CMD 文件各段含…
    基于TMS320F2812集中供电系统…
    TMS320F2812的CMD文件配置详…
    基于TMS320F2812的多轴伺服控…
    利用TMS320F2812 DSP&DRV592…
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    站长:61IC 湘ICP备05002478号