📄 gp timer as core timer.asm
字号:
/* 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)
/* Main code section */
.global _main;
.section/pm seg_pmco;
_main:
/* Using PWM Out mode as a core timer */
ustat3 = TIMODEPWM| /* PWM Out Mode */
PRDCNT| /* Count to end of period */
IRQEN;
dm(TM0CTL) = ustat3;
R0 = 0x8000;
dm(TM0PRD) = R0; /* Timer 0 period = 0x8000 */
R1 = 1;
dm(TM0W) = R1; /* Timer 0 Pulse width = 1 */
R0 = TIM0EN; /* enable timer 0 */
dm(TMSTAT) = R0;
/* Get start clock count */
R1 = EMUCLK;
// Wait until TIM0IRQ is set
// Alternatively, we could test GPTMR0I in IRPTL
r0=dm(TMSTAT);
btst r0 by 0;
if not sz jump (pc,2);
jump(pc,-3) (db);
/* Get end clock count */
R2=EMUCLK;
/* Subtract the start count from the end count
to obtain the number of cycles before the interrupt */
R4=R2-R1;
// R4 will be double the value of TM0PRD
_main.end: jump(pc,0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -