⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timer.c

📁 针对ti c6713 dsk的flashburn烧写程序
💻 C
字号:
/*******************************************************************************
 * Copyright 2004-2005 - Software Design Solutions, Inc.  All rights reserved.
 *
 * Portions of this work have been provided under license with Texas 
 * Instruments Inc.
 * 
 * $RCSfile: timer.c,v $
 * $Revision: 1.2 $
 * 
 * Description: Timer delay code
 *
 ******************************************************************************/
#define timer_c

/*---- compilation control switches ----------------------------------------*/

/*****************************************************************************
* INCLUDE FILES
*****************************************************************************/
/*---- system and platform files -------------------------------------------*/
#include <stdlib.h>
#include <stdio.h>
#include <c6x.h>
/*---- program files -------------------------------------------------------*/

#include "c6713dsk.h"

/*****************************************************************************
* EXTERNAL REFERENCE    
*****************************************************************************/
/*---- data declarations ---------------------------------------------------*/

/*---- function prototypes -------------------------------------------------*/

/*****************************************************************************
* PUBLIC DECLARATIONS 
*****************************************************************************/

/*---- data declarations ---------------------------------------------------*/
TIMER_Handle hTimer = NULL;


/*****************************************************************************
* PRIVATE DECLARATIONS  
*****************************************************************************/
/*---- context -------------------------------------------------------------*/
/*---- data declarations ---------------------------------------------------*/
/*---- function prototypes -------------------------------------------------*/
/*---- macros --------------------------------------------------------------*/

/*****************************************************************************
* PUBLIC FUNCTION DEFINITIONS
*****************************************************************************/

/*****************************************************************************
* NAME:   TIMER_Init()
*
* DESCRIPTION: Setup our timer that is used for all TEB examples.       
*       
* NOTES:
*   
*****************************************************************************/
void TIMER_Init(void)
{
    TIMER_Config myTimerConfig;  
                 
    hTimer = TIMER_open(TIMER_DEVANY, TIMER_OPEN_RESET);
    TIMER_getConfig( hTimer, &myTimerConfig);
    myTimerConfig.ctl &= 0xff3f;
    myTimerConfig.ctl |= 0x200;
    myTimerConfig.prd = 0xFFFFFFFF;
    myTimerConfig.cnt = 0x00000000;
    TIMER_config(hTimer, &myTimerConfig);

    TIMER_start(hTimer);
    TIMER_pause(hTimer);
}

/*****************************************************************************
* NAME:   TIMER_DelayMsec()
*
* DESCRIPTION: Simple delay based on 500 MHz DSP clock.       
*       
* NOTES:
*   
*****************************************************************************/

void TIMER_DelayMsec(short msec)
{ 
    /* Assume 500 MHz CPU, timer period is CPUCLK/8 for C64x */
    Uint32 timer_limit = (msec*62500);
    Uint32 time_start;
    Uint32 time_current;

    if( hTimer == NULL )
    {
        return;
    }
      
    time_start = TIMER_getCount(hTimer);
    TIMER_resume(hTimer);
    do
    {
        time_current = TIMER_getCount(hTimer);
    } while ((time_current-time_start) < timer_limit);
}

⌨️ 快捷键说明

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