gp timer as core timer.c
来自「ADI 公司的DSP ADSP21262 EZ-KIT LITE开发板的全部源代」· C语言 代码 · 共 41 行
C
41 行
#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 + =
减小字号Ctrl + -
显示快捷键?