|
- void Receive_RS485(void) interrupt 7 using 2
- {
- unchar temp, n;
- RI1=0; //??????????±ê????
- temp=SBUF1;
- //////////////// 接受标志位 //////////////////////////
- if(stop_flag == 0)
- {
- if(temp==0x7e)
- {
- start_flag=1;
- length_485=0;
- }
- //////////////// 数据接收//////////////////////////
- if(start_flag==1)
- {
- receive_buffer_485[length_485]=temp;
- ++length_485;
- if(length_485==55)
- {
- receive_check_485=0;
- RDflag_485=1;
- length_485=0;
- for(n=1; n<54; n++)
- {
- receive_check_485+=receive_buffer_485[n];
- }
- if(receive_check_485==receive_buffer_485[54])
- {
- //green=0;
- error_485=0;
- start_flag=0;
- length_485=0;
- EXIF|=0x80;
- }
- else
- {
- start_flag=0;
- error_485=1;
- length_485=0;
- //green=1;
- }
- }
- }
- }
- ES1=1; }
复制代码 |
|