共2条
1/1 1 跳转至页
再次询问各位,有关定时器脉冲计数
问
以下是我使用Pin0.2捕获脉冲,捕获一次就产生一个中断,然后用一个全局变量计数,是否有一些轻量级的做法,为什么不能直接读一个计数寄存器呢?
请各位高手指点,万分感谢!
#include <LPC21xx.H>
void T0isr(void) __irq;
unsigned long count=0;
int main(void)
{
VPBDIV = 0x00000002; //Set pclk to 30 Mhz
PINSEL0 = 0x00000020; //Enable pin 0.2 as capture channel0
T0PR = 0x0000001E; //Load prescaler for 1 Msec tick
T0TCR = 0x00000002; //Reset counter and prescaler
T0CCR = 0x00000005; //Capture on rising edge of channel0
T0TCR = 0x00000001; //enable timer
VICVectAddr4 = (unsigned)T0isr; //Set the timer ISR vector address
VICVectCntl4 = 0x00000024; //Set channel
VICIntEnable = 0x00000010; //Enable the interrupt
while(1)
{
;
}
}
void T0isr (void) __irq
{
static int value;
value = T0CR0; // read the capture value
T0IR |= 0x00000001; //Clear match 0 interrupt
VICVectAddr = 0x00000000; //Dummy write to signal end of interrupt
count++;
}
答 1: LPC2220具有外部事件计数器 答 2: 那2119有吗?? 答 3: ZLG在哪里讲了外部事件计数器? 答 4: 那位贴一段脉冲计数的代码吧,谢谢 答 5: 真的没人在LPC2119上做计数吗?能否贴段代码??
请各位高手指点,万分感谢!
#include <LPC21xx.H>
void T0isr(void) __irq;
unsigned long count=0;
int main(void)
{
VPBDIV = 0x00000002; //Set pclk to 30 Mhz
PINSEL0 = 0x00000020; //Enable pin 0.2 as capture channel0
T0PR = 0x0000001E; //Load prescaler for 1 Msec tick
T0TCR = 0x00000002; //Reset counter and prescaler
T0CCR = 0x00000005; //Capture on rising edge of channel0
T0TCR = 0x00000001; //enable timer
VICVectAddr4 = (unsigned)T0isr; //Set the timer ISR vector address
VICVectCntl4 = 0x00000024; //Set channel
VICIntEnable = 0x00000010; //Enable the interrupt
while(1)
{
;
}
}
void T0isr (void) __irq
{
static int value;
value = T0CR0; // read the capture value
T0IR |= 0x00000001; //Clear match 0 interrupt
VICVectAddr = 0x00000000; //Dummy write to signal end of interrupt
count++;
}
答 1: LPC2220具有外部事件计数器 答 2: 那2119有吗?? 答 3: ZLG在哪里讲了外部事件计数器? 答 4: 那位贴一段脉冲计数的代码吧,谢谢 答 5: 真的没人在LPC2119上做计数吗?能否贴段代码??
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
【笔记】生成报错synthdesignERROR被打赏50分 | |
【STM32H7S78-DK评测】LTDC+DMA2D驱动RGBLCD屏幕被打赏50分 | |
【STM32H7S78-DK评测】Coremark基准测试被打赏50分 | |
【STM32H7S78-DK评测】浮点数计算性能测试被打赏50分 | |
【STM32H7S78-DK评测】Execute in place(XIP)模式学习笔记被打赏50分 | |
每周了解几个硬件知识+buckboost电路(五)被打赏10分 | |
【换取逻辑分析仪】RA8 PMU 模块功能寄存器功能说明被打赏20分 | |
野火启明6M5适配SPI被打赏20分 | |
NUCLEO-U083RC学习历程2-串口输出测试被打赏20分 | |
【笔记】STM32CUBEIDE的Noruletomaketarget编译问题被打赏50分 |