发表于:2011/4/14 14:52:46
#0楼
我有一块开发板,我想用上面的4个按键,每按一个,串口调试软件里都应该接收到一个数字,可是弄完啥反映也没有,下面有提示,但不太明白,哪位大侠帮忙看看~!
#include<reg52.h>
typedef unsigned char uint8;
typedef unsigned int uint16;
sbit KeyIn1=P2^4;
sbit KeyIn2=P2^5;
sbit KeyIn3=P2^6;
sbit KeyIn4=P2^7;
sbit KeyOut1=P2^3;
sbit KeyOut2=P2^2;
sbit KeyOut3=P2^1;
sbit KeyOut4=P2^0;
uint8 num=0;
void UART_init(void) //通讯初始化//
{
SCON=0x50;
TMOD=0x20;
TH1=0xFD;
TL1=0XFD;
TR1=1;
}
void UART_send_byte(uint8 dat) //发送 子程序//
{
SBUF=dat;
while(!TI);
TI=0;
}
main() //主程序//
{
KeyOut1=0;
UART_init();
while(1);
{
if (KeyIn1==0|KeyIn2==0|KeyIn3==0|KeyIn4==0)
{
UART_send_byte(num++);
}
}
}
下面提示为:#include<reg52.h>
WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?—uart_send_byte?INT0
这个发送子程序有什么错误呢??
#include<reg52.h>
typedef unsigned char uint8;
typedef unsigned int uint16;
sbit KeyIn1=P2^4;
sbit KeyIn2=P2^5;
sbit KeyIn3=P2^6;
sbit KeyIn4=P2^7;
sbit KeyOut1=P2^3;
sbit KeyOut2=P2^2;
sbit KeyOut3=P2^1;
sbit KeyOut4=P2^0;
uint8 num=0;
void UART_init(void) //通讯初始化//
{
SCON=0x50;
TMOD=0x20;
TH1=0xFD;
TL1=0XFD;
TR1=1;
}
void UART_send_byte(uint8 dat) //发送 子程序//
{
SBUF=dat;
while(!TI);
TI=0;
}
main() //主程序//
{
KeyOut1=0;
UART_init();
while(1);
{
if (KeyIn1==0|KeyIn2==0|KeyIn3==0|KeyIn4==0)
{
UART_send_byte(num++);
}
}
}
下面提示为:#include<reg52.h>
WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?—uart_send_byte?INT0
这个发送子程序有什么错误呢??
切记~~!勿浮躁~~!