#include
#include "string.h"
#include "stdio.h"
#include "stdlib.h"
#define Fosc 24000000 //24.0MHZ
#define Tc 1 //ms
#define CTC0_RELOAD_H 0xb1 //Tc/12/Fosc/100;(12T)
#define CTC0_RELOAD_L 0xe0 //Tc/1/Fosc/100;(1T)
#define TIME_OVER 6000 //时间片 1s=1000
#define CLEAR_S2TI 0xFD //1111 1101
#define CLEAR_S2RI 0xFE //1111 1110
struct ICXX_Message
{
......
};
struct ICJC_Message
{
.......
};
sbit MCU_Debug_Led=P1^4;
struct ICXX_Message icxxdata;
struct ICJC_Message icjcdata;
unsigned char Current_Address[4];
xdata unsigned char One_Rec_Buffer[30]; //串口接收缓存
xdata unsigned char Two_Rec_Buffer[256];
xdata unsigned int counst1; //串口计数器
xdata unsigned int counst2;
unsigned int time_slice=1; //时间计数器 CTC0中断一次加1
unsigned char flag_time;
unsigned char flag_rec;
unsigned char flag_send;
unsigned char One_Send_Ok; //串口1接收结束
unsigned int One_end_flag ; //串口1接收到结束符标志
unsigned char Two_Send_Ok; //串口2接收结束
void Wink_Led(unsigned int time);
void Serial_One_Initial(unsigned int band1);
void Serial_One_Send_Byte(char c1);
void Serial_One_Interrupt_Receive();
void Serial_Two_Initial(unsigned int band2);
void Serial_Two_Send_Byte(char c2);
void Serial_Two_Interrupt_Receive();
void Delay(int time);
void main()
{
flag_time=0;
One_Send_Ok=0; //信号量初始化
Two_Send_Ok=0;
One_end_flag=0;
flag_time=0;
flag_rec=0;
flag_send=0;
counst1=0;
counst2=0;
memset(One_Rec_Buffer,0,30);
memset(Two_Rec_Buffer,0,256);
Serial_One_Initial(9600); //串口初始化
Serial_Two_Initial(9600);
Serial_One_Send_Byte('A');
while (counst10)
{
i--;
MCU_Debug_Led=0;
for(count=0;count