有谁用过msm7512啊,我是写软件的,已经写好了,但硬件还没做出来,所以还不能调试,我把我的程序贴上来大家看一下是对的不 先弄发送部分的 #include <reg51.h> #include <intrins.h> #define uchar unsigned char #define uint unsigned int sbit key1=P1^3; sbit key2=P1^4; //按键按一下发送一个0 sbit key3=P1^5; //发送一个1 void delay(int ms) { while(ms--) { uchar i; for(i=0;i<250;i++) { _nop_(); _nop_(); _nop_(); _nop_(); } } } void send() { P0=0x08; //smod1,smod(p0.0,p0.1)为00,rs(P0^2)为低电平允许发送,cd(P0^3)保持为高电平 PCON=0x00; EA=1; ET1=1; TMOD=0x20; SCON=0x72; TH1=0xE8; TL1=0XE8; //1200bit/s TR1=1; //TI=0; } void fasong() { key1=0; if (key2 == 0) { delay(5); while(!key2); delay(5); while(TI == 0); SBUF = '0'; TI = 0; } if (key3 == 0) { delay(5); while(!key3); delay(5); while(TI == 0); SBUF = '1'; TI = 0; } } void main() { send(); while(1) { fasong(); } }
|