No.97267 作者:czoowl 邮件:czoowl@sohu.com ID:50561 登陆:9次 文章数:13篇 最后登陆IP:221.221.166.3 最后登陆:2007/9/18 10:44:30 注册:2006/4/4 9:34:43 财富:147 发帖时间:2006/8/30 21:35:18 发贴者IP:218.18.49.105 标题:czoowl:请大家帮我看看程序 摘要:No.97267请大家帮我看看程序 51单片机,用T2方波发生器发射方波,用74HC259分成八路分时输出由两个按键控制,一个按键P1_2控制通道的切换,另一个按键P1_3按下时发射方波。 我的程序在KeilC编译的时候总是有Warning,下面把程序和Warning给大家看看,请多多指点,看看问题出在哪里了。 程序: /************************************************************ SAmain.c Name: 新背投六轴控制程序 Creat: 2006/08/29 ************************************************************/ #define uchar unsigned char #define uint unsigned int //#include "89c55wd.h" #include <AT89X55.H> uchar bdata channel_num = 0x00; uchar bdata work_flag = 0x00; sbit one_pulse = work_flag^0; // 1:single step complete sbit run_stop = work_flag^1; // 1:run 0:stop void delay (uchar h_data) { uchar bdata l_data; while (h_data--) { for (l_data = 0x00; l_data < 0xff; l_data++); } } void initialize (void) { EA = 0; EX0 = 0; T2CON = 0x00; T2MOD = T2MOD|0x02; RCAP2H = 0x00; RCAP2L = 0x00; IE = 0x01; //INT0 IT0 = 1; //edge run_stop = 0; } uchar keyscan (void) { uchar bdata time_delay = 0x10; uchar bdata p1_bak; uchar bdata result = 0x00; if (P1 & 0x0c != 0x0c) { delay (time_delay); if (P1 & 0x0c != 0x0c) { p1_bak = P1 & 0x0c; if (p1_bak == 0x08) result = 0x01; if (p1_bak == 0x04) result = 0x02; } } return (result); } void main(void) { uchar bdata key_order; uchar bdata i, j; uchar bdata onestep_delay; initialize(); EA = 1; while (1) { key_order = keyscan(); if (key_order == 0x01) { channel_num++; if (channel_num > 0x06) channel_num = 0x00; switch (channel_num) { case 0: P1_4 = 0; P1_5 = 0; P1_6= 0; break; case 1: P1_4 = 1; P1_5 = 0; ......
>>返回讨论的主题
|