|
51單片機(jī)串口編譯出錯(cuò)什么問題
..\source\main.c(25): error C100: unprintable character 0xB4 skipped
第25行報(bào)錯(cuò)
#include <reg51.h>
#include "delay.h"
#include "uart.h"
sbit LED1=P1^0;
sbit LED2=P1^1;
sbit LED3=P1^2;
sbit LED4=P1^3;
void Timer0Init(void);
void main()
{
unsigned char i;
Timer0Init();
UartInit();
EA=1;//打開總中斷
printf("wait for serial communication test.\r\n");
printf("please send a command\r\n");
while(1)
{
if(recv_flag)
{
recv_flag=0;
start_timer=0;//關(guān)定時(shí)器
sendString(recv_buf);/處理數(shù)據(jù)
clr_recvbuffer(recv_buf);//清除數(shù)據(jù)buf
}
}
}
void Timer0Init(void) //1毫秒@11.0592MHz
{
//==AUXR &= 0x7F; //定時(shí)器時(shí)鐘12T模式
TMOD &= 0xF0; //設(shè)置定時(shí)器模式
TMOD |= 0x01; //設(shè)置定時(shí)器模式
TL0 = 0x66; //設(shè)置定時(shí)初值
TH0 = 0xFC; //設(shè)置定時(shí)初值
TF0 = 0; //清除TF0標(biāo)志
ET0=1;//打開定時(shí)計(jì)數(shù)器0
TR0 = 1; //定時(shí)器0開始計(jì)時(shí)
}
void timer0_ISR() interrupt 1
{
TR0=0;
if(start_timer==1)
{
recv_timer_cnt++;//1、累加定時(shí)時(shí)間計(jì)數(shù)器
if(recv_timer_cnt>MAX_REV_TIME)//2、判斷定時(shí)時(shí)間是否超過設(shè)定的最大閾值,
//超過則說明等待一段時(shí)間后沒有新的數(shù)據(jù)到,
//我們就判斷一包數(shù)據(jù)接受完畢
{
recv_timer_cnt=0;//3、清除定時(shí)計(jì)數(shù)器 處理數(shù)據(jù)清楚buffer(放到數(shù)據(jù)處理之后)
recv_cnt=0;
recv_flag=1;
}
}
TL0 = 0x66; //設(shè)置定時(shí)初值
TH0 = 0xFC; //設(shè)置定時(shí)初
TR0=1;
}
|
|