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

📄 gp timer as core timer.c

📁 ADI 公司的DSP ADSP21262 EZ-KIT LITE开发板的全部源代码
💻 C
字号:
#include <signal.h>

/* Register Definitions */
#define TMSTAT (0x1400)  /* GP Timer Status Register */
#define TM0CTL (0x1401)  /* GP Timer 0 Control Register */
#define TM0PRD (0x1403)  /* GP Timer 0 Period Register */
#define TM0W   (0x1404)  /* GP Timer 0 Width Register */

/* Bit Definitions */
#define TIMODEPWM   (0x00000001)
#define PRDCNT      (0x00000008)
#define IRQEN       (0x00000010)
#define TIM0EN      (0x00000100)
#define TIM0IRQ     (0x00000001)

void timer_interrupt(int sig_int)
{
    // Clear the interrupt manually to continue using the timer.
    * (volatile int *) TMSTAT = TIM0IRQ;
}

/* Main code section */
void main()
{
    interrupt(SIG_GPTMR0,timer_interrupt);

    /* Using PWM Out mode as a core timer */
    * (volatile int *) TM0CTL = TIMODEPWM|     /* PWM Out Mode */
                                PRDCNT|        /* Count to end of period */
                                IRQEN;

    * (volatile int *) TM0PRD = 0x8000;        /* Timer 0 period = 0x8000 */

    * (volatile int *) TM0W = 1;               /* Timer 0 Pulse width = 1 */

    * (volatile int *) TMSTAT = TIM0EN;            /* enable timer 0 */
    
    while(1)
    {}
}

⌨️ 快捷键说明

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