智能车制作
标题:
急求欧姆龙测速程序
[打印本页]
作者:
米高扬
时间:
2011-5-29 22:17
标题:
急求欧姆龙测速程序
谁有欧姆龙测速的程序啊,我们的自己写的程序不知怎的捕捉不到脉冲,想借大家的程序试试 发到
676356489@qq.com
,非常感谢
作者:
星梦追影
时间:
2011-5-30 19:21
麻烦也给我发一下把
1018421427@qq.com
,谢谢!
作者:
SCU
时间:
2012-6-6 16:53
同求:
1543447409@qq.com
作者:
渭州刀客
时间:
2013-3-22 22:16
同求
568129723@qq.com
作者:
王彦杰
时间:
2013-3-29 22:29
#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
#include<MC9S12XS128.h>
//该程序统计5秒内转了多少圈
word num;
uchar flag,ch;
void pll_init() //超频24MHz F_bus=12Mhz
{
REFDV=3;
SYNR=2;
while(CRGFLG_LOCK==0);
CLKSEL=0x80;
}
void PIT_init() {
PITCFLMT=0X81;
PITFLT=0X01;
PITCE=0X01;
PITMUX=0X0E;
PITINTE=0X01;
PITMTLD0=239; //100ms定时
PITLD0=0X1388;
}
void PA_init() {
PACTL=0X50;//开启脉冲累加功能,上升沿计数,输入时钟为PA预分频时钟脉冲累加溢出中断使能,输入中断使能
PACNT=0x0000;//清零
TCTL3=0X40;
TIE=0X00;
TIOS=0X00;
}
void sci_init() {
SCI0BDH=0X00;
SCI0BDL=0X9c; //波特率4800
SCI0CR1=0X00; //8位模式无奇偶校验
SCI0CR2=0X2C; // 发送允许,接受中断
}
//接收函数
unsigned char SCI_READ() {
if(SCI0SR1_RDRF==1) {
SCI0SR1_RDRF=1;
return (SCI0DRL);
}
}
//发送函数
unsigned char SCI_WRITE(unsigned char n) {
while(!(SCI0SR1_TDRE));
SCI0DRH=0;
SCI0DRL=n;
}
void main(void) {
pll_init();
PIT_init();
PA_init();
sci_init();
EnableInterrupts;
for(;;) {
} /* loop forever */
/* please make sure that you never leave main */
}
#pragma CODE_SEG NON_BANKED
void interrupt 66 PIT0() {
flag++;
if(flag==50) {
flag=0;
num=PACNT;
ch=num/200;
SCI_WRITE(ch);
PACNT=0X0000;
}
PITTF=0X01;
}
欢迎光临 智能车制作 (http://111.231.132.190/)
Powered by Discuz! X3.2