No.95594 作者:realzuoluo 邮件:cruize@yeah.net ID:54013 登陆:3次 文章数:3篇 最后登陆IP:202.120.49.68 最后登陆:2006/8/12 10:47:13 注册:2006/5/26 15:35:54 财富:117 发帖时间:2006/7/12 22:35:46 发贴者IP:219.228.116.64 标题:realzuoluo:80c552做计数编码器信号的程序,请大家指点看看是不是有问题呀?谢谢 摘要:No.9559480c552做计数编码器信号的程序,请大家指点看看是不是有问题呀?谢谢 用外部中断1,记录编码器A象信号,用T1记录B象脉冲信号,同时把B项信号,接到p1.0,用来测试外部中断发生脉冲触发时候,B项状态,判断转向。定时设置0.1s进行采样计数 #include <REG552.H> sbit P1_0 = P1^0; sbit P1_1 = P1^1; sbit P1_2 = P1^2; sbit P1_3 = P1^3; /*------------------------------------------------------------------------------ main() : Runs a while loop as the PWM automatically loops ------------------------------------------------------------------------------*/ unsigned char Counter; unsigned int Pluse; void main( void ) { Counter = 2; P1_0 = 0x01; P1_2 = 0X01; P1_3 =0X01; PWMP = 0x0A; //Set the repition frequenct to 2.14kHz PWM1 = 0x00; //Set the Duty cycle to 100% EA=1; //总中断允许 ......
>>返回讨论的主题
|