📄 distm.lst
字号:
577 1
578 1 }
579 void send_inf(void)
580 {
581 1 uint16 i,j,start_octet,end_octet;
582 1 lenth[2]=BCD_D(lenth[2]);
583 1 lenth[3]=BCD_D(lenth[3]);
584 1 start_octet=(lenth[0]<<8)+lenth[1];
585 1 end_octet=start_octet+(lenth[2]<<8)+lenth[3];
586 1 if(rcv_inf01==0x02){
587 2 rcv_inf01=0;
588 2 while(!trans_over){}
589 2 SBUF=0xfc;trans_over=0;
590 2 while(!trans_over){}
591 2 SBUF=0x03;trans_over=0;
592 2
593 2 for(i=start_octet;i<end_octet;i++){
594 3 page_buffer2_trans(i);
595 3 delay(400);
596 3 buffer2_read(0x107,0);
597 3 delay(400);//可修改
598 3 for(j=0;j<0x107;j++){
599 4 while(!trans_over){}
600 4 SBUF=*(sp0+j);trans_over=0;
601 4 }}
602 2 }
603 1 if(rcv_inf11==0x02){
604 2 rcv_inf11=0;
605 2 while((UARTLSR&0x60)==0){}
606 2 UARTTHR=0xfc;
607 2 while((UARTLSR&0x60)==0){}
608 2 UARTTHR=0x03;
609 2 for(i=start_octet;i<end_octet;i++){
610 3 page_buffer2_trans(i);
611 3 delay(400);
612 3 buffer2_read(0x107,0);
C51 COMPILER V7.06 DISTM 06/20/2005 15:36:06 PAGE 11
613 3 delay(400);//可修改
614 3 for(j=0;j<0x107;j++){
615 4 while((UARTLSR&0x60)==0){}
616 4 UARTTHR=*(sp0+j);
617 4 }}
618 2 }
619 1
620 1 }
621 void T0_INT(void) interrupt 1 using 3
622 {//0xf000 is alarm,6k out.83.333us
623 1 TH0=0xff;
624 1 TL0=0xb3;
625 1 if(wave00){
626 2 P14=!P14;
627 2 //P15=!P15;
628 2 }
629 1 else{
630 2 P14=1;P15=1;}
631 1 if(wave01){
632 2 P16=!P16;
633 2 //P17=!P17;
634 2 }
635 1 else{
636 2 P16=1;P17=1;}
637 1 tt++;
638 1 if(tt>0x5dc0){tt=0;time_2s=1;}
639 1 if(rcv_flag){
640 2 noinf_4s++;}//2004/10/13
641 1 if(noinf_4s>0xbb80){noinf_4s=0;//bb80 4s若4秒无信息传来则落下所有继电器
642 2 wave00=0;wave01=0;
643 2 }
644 1 }
645 void EX_INT0(void) interrupt 0 using 2
646 {
647 1 uint8 i,j,k;
648 1
649 1 i=UARTRBR;
650 1 j=UARTIIR;
651 1 k=UARTLSR;
652 1 //if((UARTLSR & 0x1a) != 0){
653 1
654 1 if(!head10_over){
655 2 if(i==0xfc){ head10_over=1;}}
656 1 else if(!head11_over){if(i==0xfc){head11_over=1;}}
657 1 else if(!head12_over){ re1_c=0;
658 2 if(i==0x01){head12_over=1;rcv_inf10=1;}
659 2 else if(i==0x02){head12_over=1;rcv_inf10=2;
660 3 head10_over=0;head11_over=0;head12_over=0;}
661 2 else{ if(i==0x03){head12_over=1;rcv_inf10=3;}}}
662 1 else{
663 2 if(rcv_inf10==0x01){date[re1_c]=i;re1_c++;
664 3 if(re1_c>=6){head10_over=0;head11_over=0;head12_over=0;
665 4 rcv_inf11=1;}}
666 2 if(rcv_inf10==0x03){lenth[re1_c]=i;re1_c++;
667 3 if(re1_c>=4){rcv_inf11=2;
668 4 head10_over=0;head11_over=0;head12_over=0;}}}
669 1
670 1 //}
671 1 //MR=1;
672 1
673 1 }
674 void out_6k(void)
C51 COMPILER V7.06 DISTM 06/20/2005 15:36:06 PAGE 12
675 {
676 1 uint8 highbyte,lowbyte;
677 1 uint16 condat0;
678 1 pbuf=&rx[0];
679 1 condat0=getcrccode(pbuf,3);
680 1 lowbyte=condat0&0x00ff;
681 1 highbyte=condat0>>8;
682 1 if((lowbyte==rx[3])&&(highbyte==rx[4])){
683 2 if((rx[0]==0x44)&&(rx[1]==0x55)&&(rx[2]==0x66)){
684 3 wave00=1;wave01=0;
685 3 }
686 2 if((rx[0]==0x77)&&(rx[1]==0x88)&&(rx[2]==0x99)){
687 3 wave00=0;wave01=1;
688 3 }
689 2 if((rx[0]==0xaa)&&(rx[1]==0xbb)&&(rx[2]==0xcc)){
690 3 wave00=0;wave01=0;
691 3 }
692 2 }
693 1 }
694
695 void trans_x1x2(void)
696 {
697 1 uint8 temp0,temp1,i,j,highbyte,lowbyte;
698 1 uint16 condat0;
699 1 temp0=out_xdata&0x03;
700 1 temp1=old_out&0x03;
701 1 //temp2=out_xdata&0x30;//2004/10/9
702 1 //temp3=out_xdata&0xc0;//2004/10/9
703 1 i=temp0^temp1;
704 1 if((i!=0)||(time_2s==1)){time_2s=0;
705 2 while(!trans_over){}
706 2 SBUF=0xfc;trans_over=0;
707 2 while(!trans_over){}
708 2 SBUF=0x33;trans_over=0;
709 2
710 2 if(((out_xdata&0x03)==0x01)&&((out_xdata&0xf0)==0x00)){//2004/10/09
711 3 //if((out_xdata&0x03)==0x01){
712 3 tx[0]=0x44;
713 3 tx[1]=0x55;
714 3 tx[2]=0x66;
715 3 pbuf=&tx[0];
716 3 condat0=getcrccode(pbuf,3);
717 3 lowbyte=condat0&0x00ff;
718 3 highbyte=condat0>>8;
719 3 tx[3]=lowbyte;
720 3 tx[4]=highbyte;
721 3 for(j=0;j<5;j++){
722 4 while(!trans_over){}
723 4 SBUF=tx[j];trans_over=0;}}
724 2 if(((out_xdata&0x03)==0x02)&&((out_xdata&0xf0)==0x00)){//2004/10/09
725 3 //if((out_xdata&0x03)==0x02){
726 3 tx[0]=0x77;
727 3 tx[1]=0x88;
728 3 tx[2]=0x99;
729 3 pbuf=&tx[0];
730 3 condat0=getcrccode(pbuf,3);
731 3 lowbyte=condat0&0x00ff;
732 3 highbyte=condat0>>8;
733 3 tx[3]=lowbyte;
734 3 tx[4]=highbyte;
735 3 for(j=0;j<5;j++){
736 4 while(!trans_over){}
C51 COMPILER V7.06 DISTM 06/20/2005 15:36:06 PAGE 13
737 4 SBUF=tx[j];trans_over=0;}}
738 2 if((out_xdata&0x03)==0x00){
739 3 tx[0]=0xaa;
740 3 tx[1]=0xbb;
741 3 tx[2]=0xcc;
742 3 pbuf=&tx[0];
743 3 condat0=getcrccode(pbuf,3);
744 3 lowbyte=condat0&0x00ff;
745 3 highbyte=condat0>>8;
746 3 tx[3]=lowbyte;
747 3 tx[4]=highbyte;
748 3 for(j=0;j<5;j++){
749 4 while(!trans_over){}
750 4 SBUF=tx[j];trans_over=0;}}
751 2 old_out=out_xdata;
752 2 while(!trans_over){}
753 2 SBUF=out_xdata;trans_over=0;
754 2 }
755 1
756 1
757 1 }
758 void pick(void)
759 {uint8 i,j,k;
760 1 cj_50hz();
761 1 cj_6k();
762 1 anly_50hz(0);
763 1 andata00=mdtra;
764 1 anly_50hz(8);
765 1 andata01=mdtra;
766 1 anly_6k(16);
767 1 out_xdata=mdtra;
768 1
769 1 i=andata00^andata10;
770 1 j=andata01^andata11;
771 1 k=out_xdata^old_out;
772 1 if(i!=0){
773 2 memdata[cjtemp]=andata00;
774 2 memdata[cjtemp+1]=0x66;
775 2 cjtemp+=2;
776 2 storage();
777 2 andata10=andata00;}
778 1 if(j!=0){
779 2 memdata[cjtemp]=andata01;
780 2 memdata[cjtemp+1]=0x77;
781 2 cjtemp+=2;
782 2 storage();
783 2 andata11=andata01;}
784 1 if(k!=0){
785 2 memdata[cjtemp]=out_xdata;
786 2 memdata[cjtemp+1]=0x88;
787 2 cjtemp+=2;
788 2 storage();}
789 1 //old_out=out_xdata;}
790 1 }
791 void cj_50hz(void)
792 {//40ms采集两个周期
793 1 uint8 i,j;
794 1 for(i=0;i<40;i++){
795 2 mdtra=cjdata0;
796 2 transform(0);
797 2 mdtra=cjdata1;
798 2 transform(8);
C51 COMPILER V7.06 DISTM 06/20/2005 15:36:06 PAGE 14
799 2 //mdtra=cjdata2;
800 2 //transform(16);
801 2 for(j=0;j<152;j++)_nop_();
802 2 }
803 1 }
804 void cj_6k(void)
805 {//一周期166.7us采4次,每次用39.0625US,共采9.375周期39*40=1.56ms
806 1 uint8 i;
807 1 for(i=0;i<40;i++){
808 2 mdtra=cjdata3;
809 2 transform(16);
810 2 }
811 1 }
812
813 void transform(uint8 temp)
814 {
815 1
816 1 if(si0) ++aiha[temp];
817 1 if(si1) ++aiha[temp+1];
818 1 if(si2) ++aiha[temp+2];
819 1 if(si3) ++aiha[temp+3];
820 1 if(si4) ++aiha[temp+4];
821 1 if(si5) ++aiha[temp+5];
822 1 if(si6) ++aiha[temp+6];
823 1 if(si7) ++aiha[temp+7];
824 1 //mdtra=0;
825 1 }
826 uint8 anly_50hz(uint8 temp)
827 {
828 1
829 1 if((15<aiha[temp]) && (aiha[temp]<41))si0=1;else{si0=0;}
830 1 if((15<aiha[temp+1]) && (aiha[temp+1]<41))si1=1;else{si1=0;}
831 1 if((15<aiha[temp+2]) && (aiha[temp+2]<41))si2=1;else{si2=0;}
832 1 if((15<aiha[temp+3]) && (aiha[temp+3]<41))si3=1;else{si3=0;}
833 1 if((15<aiha[temp+4]) && (aiha[temp+4]<41))si4=1;else{si4=0;}
834 1 if((15<aiha[temp+5]) && (aiha[temp+5]<41))si5=1;else{si5=0;}
835 1 if((15<aiha[temp+6]) && (aiha[temp+6]<41))si6=1;else{si6=0;}
836 1 if((15<aiha[temp+7]) && (aiha[temp+7]<41))si7=1;else{si7=0;}
837 1 return(mdtra);
838 1 }
839 uint8 anly_6k(uint8 temp)
840 {
841 1 if((30<aiha[temp]) && (aiha[temp]<=40))si0=1;else{si0=0;}
842 1 if((30<aiha[temp+1]) && (aiha[temp+1]<=40))si1=1;else{si1=0;}
843 1 si2=0;si3=0;
844 1 if(aiha[temp+7]==40)si4=1;else{si4=0;}
845 1 if(aiha[temp+6]==40)si5=1;else{si5=0;}
846 1 if(aiha[temp+5]==40)si6=1;else{si6=0;}
847 1 if(aiha[temp+4]==40)si7=1;else{si7=0;}
848 1 return(mdtra);
849 1 }
850
851
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 3956 ----
CONSTANT SIZE = 24 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 47
IDATA SIZE = ---- ----
C51 COMPILER V7.06 DISTM 06/20/2005 15:36:06 PAGE 15
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -