TI C281x Timer Configuration
This code configures the CPU Timer 0 of the family C281x from Texas Instruments to generate an interruption at a rate of 2 Hz assuming 150 Mhz of system clock frequency.
**********************************************************************/
#include "DSP281x_Device.h"
/**********************************************************************
* Function: InitTimer()
*
* Description: Initialize the CPU Timer 0 at a rate of 2 Hz
**********************************************************************/
void InitTimer(void)
{
//CpuTimer0Regs.TIM.all = 0x0; //Timer0 Counter Register
CpuTimer0Regs.PRD.all = 0x047868C0; //Period Register
CpuTimer0Regs.TCR.all = 0x4830; //Control Register
/*
bit 15 0: CPU-Timer Interupt Flag
bit 14 1: Timer Interrupt Enable
bit 13-12 0's: Reserved
bit 11-10 10: CPU-Timer Emulation Modes
bit 9-6 0's: Reserved
bit 5 0: CPU-Timer Reload bit
bit 4 0: CPU-Timer Status Bit
bit 3-0 0's: Reserved
*/
CpuTimer0Regs.TPR.all = 0x0000; //Prescale Register
CpuTimer0Regs.TPRH.all = 0x0000; //Prescale Register High
PieCtrlRegs.PIEIER1.bit.INTx7 = 1; //Interruption enabled
IER |= 0x0001; //PIE group enabled
StartCpuTimer0();//Reset of the Timer
}