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

📄 gp timer pwm and width capture.asm

📁 ADI 公司的DSP ADSP21262 EZ-KIT LITE开发板的全部源代码
💻 ASM
字号:
/* Register Definitions */
#define TMSTAT  (0x1400)   /* GP Timer 0 Status register  */
#define TM0CTL  (0x1401)   /* GP Timer 0 Control register */
#define TM0CNT  (0x1402)   /* GP Timer 0 Count register   */
#define TM0PRD  (0x1403)   /* GP Timer 0 Period register  */
#define TM0W    (0x1404)   /* GP Timer 0 Width register   */
#define TM1CTL  (0x1409)   /* GP Timer 1 Control register */
#define TM1CNT  (0x140A)   /* GP Timer 1 Count register   */
#define TM1PRD  (0x140B)   /* GP Timer 1 Period register  */
#define TM1W    (0x140C)   /* GP Timer 1 Width register   */
#define SRU_PIN0         (0x2460)
#define SRU_PBEN0        (0x2478)
#define SRU_EXT_MISCB    (0x2471)

/* Bit Definitions */
#define TIMODEPWM 0x00000001
#define TIMODEW   0x00000002
#define PULSE     0x00000004
#define PRDCNT    0x00000008
#define IRQEN     0x00000010
#define TIM0EN    0x00000100
#define TIM1EN    0x00000400
#define GPTMR1I   0x00000010

/* SRU definitions */
#define TIMER0_Od       0x2C
#define TIMER0_Oe       0x14
#define PBEN_HIGH_Of    0x01

/* Bit positions */
#define TIMER1_I        5

/* Main code section */
.global _main;
.section/pm seg_pmco;
_main:
/* Set up and enable Timer 0 in PWM Out mode*/
/* Route Timer 0 Output to DAI Pin 1 via SRU */
r0=TIMER0_Od;
dm(SRU_PIN0)=r0;

/* Enable DAI Pin 1 as an output */
r0=PBEN_HIGH_Of;
dm(SRU_PBEN0)=r0;

ustat3 = TIMODEPWM|     /* PWM Out Mode */
         PULSE|         /* Positive edge is active */
         PRDCNT;        /* Count to end of period */
dm(TM0CTL) = ustat3;

R0 = 0xFF;
dm(TM0PRD) = R0;    /* Timer 0 period = 255 */

R1 = 0x3F;
dm(TM0W) = R1;      /* Timer 0 Pulse width = 15 */

R0 = TIM0EN;            /* enable timer 0 */
dm(TMSTAT) = R0;

/* --------------End of Timer 0 Setup-------------------- */

/* Set up and enable Timer 1 in Width Capture mode */
/* Use the output of Timer 0 as the input to Timer 1 */
/* Route Timer 0 Output to Timer 1 Input via SRU */
r0=(TIMER0_Oe<<TIMER1_I);
dm(SRU_EXT_MISCB)=r0;

ustat3 = TIMODEW|       /* PWM Out Mode */
         PULSE|         /* Positive edge is active */
         IRQEN|         /* Enable Timer 1 Interrupt */
         PRDCNT;        /* Count to end of period */
dm(TM1CTL) = ustat3;

ustat3 = TIM1EN;            /* enable timer 1 */
dm(TMSTAT) = ustat3;

/* Poll the Timer 1 interrupt latch, the interrupt will
latch when the measured period and pulse width are ready to
read */
bit tst LIRPTL GPTMR1I;
if not tf jump(pc,-1);

/* Read the measured values */
r0=dm(TM1PRD);
r1=dm(TM1W);
/* r0 and r1 will match the Timer 0 settings above */

_main.end: jump (pc,0);

⌨️ 快捷键说明

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