这个太简单了,就五个寄存器,看一下就行了
贴代码记录之:
/*********************************************
标题:TIMER_test.c
软件平台:CCS v5.2
硬件平台:C2000 LaunchPad
主频:60M
描述:练习定时器
基于2802x C/C++ Header Files V1.26
author:小船
data:2012-09-26
As supplied, this project is configured for "boot to SARAM"
operation. The 2802x Boot Mode table is shown below.
$Boot_Table
While an emulator is connected to your device, the TRSTn pin = 1,
which sets the device into EMU_BOOT boot mode. In this mode, the
peripheral boot modes are as follows:
Boot Mode: EMU_KEY EMU_BMODE
(0xD00) (0xD01)
---------------------------------------
Wait !=0x55AA X
I/O 0x55AA 0x0000
SCI 0x55AA 0x0001
Wait 0x55AA 0x0002
Get_Mode 0x55AA 0x0003
SPI 0x55AA 0x0004
I2C 0x55AA 0x0005
OTP 0x55AA 0x0006
Wait 0x55AA 0x0007
Wait 0x55AA 0x0008
SARAM 0x55AA 0x000A <-- "Boot to SARAM"
Flash 0x55AA 0x000B
Wait 0x55AA Other
Write EMU_KEY to 0xD00 and EMU_BMODE to 0xD01 via the debugger
according to the Boot Mode Table above. Build/Load project,
Reset the device, and Run example
$End_Boot_Table
**********************************************/
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
#include "LEDs.h"
interrupt void tim0_isr(void);
void main(void)
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2802x_SysCtrl.c file.
InitSysCtrl();
// Step 2. Initalize GPIO:
// This example function is found in the DSP2802x_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 DSP2802x_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 DSP2802x_DefaultIsr.c.
// This function is found in DSP2802x_PieVect.c.
InitPieVectTable();
// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP2802x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
// Step 5. User specific code:
CpuTimer0Regs.TPR.bit.TDDR = 59;
CpuTimer0Regs.TPRH.bit.TDDRH = 0; //对输入时钟60分频,60M/60=1M
CpuTimer0Regs.PRD.all = 1000000;//定时1s
CpuTimer0Regs.TCR.bit.TRB = 1; //reload
CpuTimer0Regs.TCR.bit.TIE = 1; //使能中断
CpuTimer0Regs.TCR.bit.TSS = 0; //开始计数
EALLOW;
PieVectTable.TINT0 = &tim0_isr;
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; //使能PIE
PieCtrlRegs.PIEIER1.bit.INTx7 = 1; //使能int1.7
IER |= 0x0001;//使能GROUP1
EINT;
EDIS;
LEDs_init();
while(1)
{
};
}
interrupt void tim0_isr(void)
{
LED_toggle(LED0);
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
//===========================================================================
// No more.
//===========================================================================