?? uait0_1.c
字號(hào):
#include"my.h"
//使用w77e58 片內(nèi)1k SRAM, 要定義為xdata ,
//為確保使用的是片內(nèi)1k RAM, 最好和 _at_ 0x0000;聯(lián)合使用
/**************************************************
串口0隊(duì)列 pc
**************************************************/
unsigned char xdata xBuf_0[131] _at_ 0x90;
unsigned char data Seri0_SendNum;
unsigned char data Seri0_ReciNum;
/**************************************************
//串口1隊(duì)列
**************************************************/
unsigned char xdata xBuf_1[0x20] _at_ 0x120;
unsigned char xdata pagedata[128]_at_ 0x140;
unsigned char xdata *pagedataPoint;
unsigned char data Seri1_SendNum;
unsigned char data Seri1_ReciNum;
/**************************************************
//串口2隊(duì)列
**************************************************/
unsigned char xdata xBuf_2[384] _at_ 0x1C0;
bit fSeri0_Send_Ok;
bit fSeri1_Send_Ok;
bit fSeri0_Reci_Ok;
bit fSeri1_Reci_Ok;
bit fSeri2_Send_Ok;
bit fSeri2_Reci_Ok;
void uart01_init(void){
//system init ,其中串口0用定時(shí)器2,串口1用定時(shí)器1
//串口1的設(shè)置
IE=0x90; //允許總中斷和串口0的中斷
TMOD=0x20; //定時(shí)器1工作在模式1
TL1=0xfd; //baud rate=9600
TH1=0xfd;
SCON1=0x58; //工作在模式1,允許接收
PCON=0x00; // SM0=0 SM1=1 在10位異步收發(fā)模式 SMOD=0 溢出速率/32
ES1=1; //串口1中斷允許
//
SCON=0x58; //工作在模式1,接收允許
T2CON=0x30; //用定時(shí)器2做串口0的波特率發(fā)生器
RCAP2H=0xff;
RCAP2L=0xdc; // 11.0592M晶振下,baud rate=9600
TR2=1;
TR1=1;
}
void Int_serial0() interrupt 4 using 1{
// ES=0; /*關(guān)串行口中斷
if(TI){//允許中斷處理
TI = 0; //*清發(fā)送中斷標(biāo)志
if(fSeri0_Send_Ok){
if(Seri0_SendNum<130){
SBUF=xBuf_0[Seri0_SendNum];
Seri0_SendNum++;
if (Seri0_SendNum==130)
fSeri0_Send_Ok=0;//容許程序處理
}
}
}
if(RI){//允許中斷處理
RI = 0;
if(fSeri0_Reci_Ok){
if(Seri0_ReciNum<130){
xBuf_0[Seri0_ReciNum]=SBUF;
Seri0_ReciNum++;
}
if(Seri0_ReciNum==130)
fSeri0_Reci_Ok=0;//容許程序處理
}
}
// ES=1; //*開中斷/
}
/**************************************************
串口1中斷 Reader
**************************************************/
unsigned char t=2;
void Int_serial1() interrupt 7 using 1{
// ES1=0; /*關(guān)串行口中斷*/
TI_1 = 0; //清發(fā)送中斷標(biāo)志*
// if(Seri1_SendNum==23){
if(Seri1_SendNum==7){
fSeri1_Send_Ok=0; //容許程序處
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -