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

📄 tsc_example.c

📁 dsp tms320c6486的csl例程
💻 C
字号:
/*  ===========================================================================
 *   Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005, 2006
 *
 *   Use of this software is controlled by the terms and conditions found in
 *   the license agreement under which this software has been supplied.
 *   ==========================================================================
 */

/** ===========================================================================
 *   @file  Tsc_example.c
 *
 *   @path  $(CSLPATH)\example\c6486\tsc\src
 *
 *   @desc  Example of TSC CSL
 *
 * ============================================================================
 *   @n <b> Example Description </b>
 *   @n The example shows how to test the TSC.
 *       1. Enable the counter.
 *       2. Wait for some time.
 *       3. Read the timer counter value
  *      4. Wait for some time.
 *       5. Read the timer counter value
 *       6. Then check the value if it is incremented or not.
 *==============================================================================
 *
 *   <b> Test Procedure </b>
 *   @verbatim
 *      1. Configure the CCS setup to work with the emulator being used
 *      2. Please refer CCS manual for setup configuration and loading
 *         proper GEL file
 *      3. Launch CCS window
 *      4. Open project Tsc_example.pjt
 *      5. Build the project and load the .out file of the project.
 *      6. The example can be executed from the main().
 *
 *   @endverbatim
 *
 *
 * =============================================================================
 */

/* ============================================================================
 *  Revision History
 *  ===============
 *  27-Jul-2005 ds created
 *  14-Nov-2005 ds modified  - Removed Ctimer related APIs and Added TSC APIs
 * ============================================================================
 */

#include <stdio.h>
#include <csl_tsc.h>

/* Macro that gives 1 CLK delay cycles */
#define WAIT_FOR_1_CLK  do {                               \
                            volatile int delayCnt = 1;      \
                            while(delayCnt > 0) --delayCnt; \
                           }while (0)

/* Forward declaration */
void tsc_example (void);

/* Globals */
Uint32      exampleFailed = 0;

/*
 * ============================================================================
 *   @func   main
 *
 *   @desc
 *     This is the main routine for the file.
 *
 * ============================================================================
 */
void main(void)
{

    /* Invoke example */
    tsc_example ();

    if (exampleFailed > 0) {
        printf ("Time Stamp Counter Example Failed[Tests Failed: %d]\n", \
                exampleFailed);
    }
    else {
        printf ("Time Stamp Counter Example Passed\n");
    }

    printf("==============================================================\n");
}

/*
 * =============================================================================
 *   @func  tsc_example
 *
 *   @arg
 *      NONE
 *
 *   @desc
 *      This is the routine which perform tsc test
 *
 *   @return
 *      NONE
 *
 * =============================================================================
 */
void tsc_example (void)
{
    CSL_Uint64          counterVal;

    printf("Running TSC CSL example\n");

    printf("Enable the Time Stamp Counter\n");

    /* Enable the TSC */
    CSL_tscEnable();

    /* Give small delay */
    WAIT_FOR_1_CLK;

    /* Read the counter value */
    counterVal = CSL_tscRead();

    /* Give small delay */
    WAIT_FOR_1_CLK;

    /* Read the counter value */
    counterVal = CSL_tscRead();

    /* Verify the counter value incremented or not */
    if(counterVal > 0) {
        printf("Increment in the time stamp counter value\n");
        printf ("counterVal = 0x%x\n", counterVal);
    }
    else {
        printf("Not increment in the  time stamp counter value\n");
        printf ("counterVal = 0x%x\n", counterVal);
        exampleFailed++;
        return;
    }

    return;
}

⌨️ 快捷键说明

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