timerinit.c

来自「CHP 2 - Real-Time Digital Signal Process」· C语言 代码 · 共 52 行

C
52
字号
// 
//  Project: Experiment 2.10.3 DSP Timer - Chapter 2 
//  File name: timerInit.c   
//
//  Function(s): initTimer()        
//
//  Description: This function shows how to initialize the DSP timer registers
//
//  For the book "Real Time Digital Signal Processing: 
//                Implementation and Application, 2nd Ed"
//                By Sen M. Kuo, Bob H. Lee, and Wenshun Tian
//                Publisher: John Wiley and Sons, Ltd
//
//  Tools used: CCS v.2.12.07
//              TMS320VC5510 DSK Rev-C
//

#include "timer.h"

#pragma CODE_SECTION(initTimer,  ".text:example:timer0");

void initTimer(void)
{                          
  asm("\tBSET   #ST1_INTM, ST1_55"); 

  //clear pending interrupts
  *IFR0  = 0xffff;               // Clear any pending interrupts              
    
  *TCR0  = TSS_BIT;              // Stop timer   
  *TCR0 &= ~(SOFT_BIT|FREE_BIT); // Init TCR       
  *TCR0 |= (TSS_BIT|TDDR_SET);   // Set new TDDR value

  *TCR0  |= FUNC_BIT;
  *PRSC0 &= 0xFFF0;    
  *PRSC0 |= TDDR_SET;        
    
  *PRD0  = PRD_SET;              // Set new PRD value
  *TCR0 |= (TLB_BIT|ARB_BIT);    // Reload PRD
 
  asm("\tNOP");
  asm("\tNOP");              
    
  *TCR0 &= ~TLB_BIT;             
  *IER0 |= TINT_BIT;             // Enable timer interrupt   
    
  asm("\tBCLR   #ST1_INTM, ST1_55");
}




⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?