?? gp timer as core timer.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 + -