📄 celiange.lst
字号:
781 3 if(j>=128)
782 3 {
783 4 j=0;
784 4 }
785 3 writepixel(p[j],i);
786 3 j=j+freq;
787 3 }
788 2 }
789 1 }
790
791 void printnum(uchar number,uchar x,uchar y)
792 {
793 1 uchar *p=&num[number][0];
794 1 print1(p,x,y);
795 1 }
796
797
798
799 void start_iic()
C51 COMPILER V6.23a CELIANGE 05/30/2007 12:24:19 PAGE 14
800 {
801 1 SDA=1;
802 1 _Nop();//1us
803 1 SCL=1;
804 1 _Nop();//5us
805 1 _Nop();
806 1 _Nop();
807 1 _Nop();
808 1 _Nop();
809 1 SDA=0;
810 1 _Nop();//5us
811 1 _Nop();
812 1 _Nop();
813 1 _Nop();
814 1 _Nop();
815 1 SCL=0;
816 1 _Nop();
817 1 _Nop();
818 1 }
819
820 void stop_iic()
821 {
822 1 SDA=0;
823 1 _Nop();
824 1 SCL=1;
825 1 _Nop();//5us
826 1 _Nop();
827 1 _Nop();
828 1 _Nop();
829 1 _Nop();
830 1 SDA=1;
831 1 _Nop();//4us
832 1 _Nop();
833 1 _Nop();
834 1 _Nop();
835 1 }
836
837 void sendbyte(uchar c)
838 {
839 1 uchar bitcnt;
840 1 for(bitcnt=0;bitcnt<8;bitcnt++)
841 1 {
842 2 if((c<<bitcnt)&0x80)SDA=1;
843 2 else SDA=0;
844 2 _Nop();
845 2 SCL=1;
846 2 _Nop();//5us
847 2 _Nop();
848 2 _Nop();
849 2 _Nop();
850 2 _Nop();
851 2 SCL=0;
852 2 }
853 1 _Nop();
854 1 _Nop();
855 1 SDA=1;
856 1 _Nop();
857 1 _Nop();
858 1 SCL=1;
859 1 _Nop();
860 1 _Nop();
861 1 _Nop();
C51 COMPILER V6.23a CELIANGE 05/30/2007 12:24:19 PAGE 15
862 1 if(SDA==1)ack=0;//没响应
863 1 else ack=1;//有响应
864 1 SCL=0;
865 1 _Nop();
866 1 _Nop();
867 1 }
868
869 uchar rcvbyte()
870 {
871 1 uchar retc;
872 1 uchar bitcnt;
873 1 retc=0;
874 1 SDA=1;
875 1 for(bitcnt=0;bitcnt<8;bitcnt++)
876 1 {
877 2 _Nop();
878 2 SCL=0;
879 2 _Nop();
880 2 _Nop();
881 2 _Nop();
882 2 _Nop();
883 2 _Nop();
884 2 SCL=1;
885 2 _Nop();
886 2 _Nop();
887 2 retc=retc<<1;
888 2 if(SDA==1)retc=retc+1;
889 2 _Nop();
890 2 _Nop();
891 2 }
892 1 SCL=0;
893 1 _Nop();
894 1 _Nop();
895 1 return(retc);
896 1 }
897
898 void ack_iic(bit a)//主机对从机的响应
899 {
900 1 if(a==0)SDA=0;
901 1 else SDA=1;
902 1 _Nop();
903 1 _Nop();
904 1 _Nop();
905 1 SCL=1;
906 1 _Nop();
907 1 _Nop();
908 1 _Nop();
909 1 _Nop();
910 1 _Nop();
911 1 SCL=0;
912 1 _Nop();
913 1 _Nop();
914 1 }
915
916 bit ISendByte(uchar sla,uchar c)
917 {
918 1 start_iic();//启动总线
919 1 sendbyte(sla);//发送器件地址
920 1 if(ack==0)return(0);
921 1 sendbyte(c);//发送数据
922 1 if(ack==0)return(0);
923 1 stop_iic();//结束总线
C51 COMPILER V6.23a CELIANGE 05/30/2007 12:24:19 PAGE 16
924 1 return(1);
925 1 }
926
927 bit ISendStr(uchar sla,uchar suba,uchar*s,uchar no)
928 {
929 1 uchar i;
930 1 start_iic();
931 1 sendbyte(sla);
932 1 if(ack==0)return(0);
933 1 sendbyte(suba);
934 1 if(ack==0)return(0);
935 1 for(i=0;i<no;i++)
936 1 {
937 2 sendbyte(*s);
938 2 if(ack==0)return(0);
939 2 s++;
940 2 }
941 1 stop_iic();
942 1 return(1);
943 1 }
944
945 bit IRcvByte(uchar sla,uchar*c)//无子地址器件接受字节数据
946 {
947 1 start_iic();
948 1 sendbyte(sla+1);
949 1 if(ack==0)return(0);
950 1 *c=rcvbyte();
951 1 ack_iic(1);
952 1 stop_iic();
953 1 return(1);
954 1 }
955
956 bit IRcvStr(uchar sla,uchar suba,uchar *s,uchar no)//有子地址器件接收字节数据
957 {
958 1 uchar i;
959 1 start_iic();
960 1 sendbyte(sla);
961 1 if(ack==0)return(0);
962 1 sendbyte(suba);
963 1 if(ack==0)return(0);
964 1 start_iic();
965 1 sendbyte(sla+1);
966 1 if(ack==0)return(0);
967 1 for(i=0;i<no-1;i++)
968 1 {
969 2 *s=rcvbyte();
970 2 ack_iic(0);
971 2 s++;
972 2 }
973 1 *s=rcvbyte();
974 1 ack_iic(1);
975 1 stop_iic();
976 1 return(1);
977 1 }
978
979 void main()
980 {
981 1 float g=0;
982 1
983 1 bit amp=0;
984 1 bit cycle=0;
985 1
C51 COMPILER V6.23a CELIANGE 05/30/2007 12:24:19 PAGE 17
986 1 float f=0;
987 1 float standard;
988 1
989 1 uint data2[11];
990 1 uchar datanum1=0;
991 1 uchar datanum2=0;
992 1 uchar result[6];
993 1 uchar keydata=0;//poll P2 port
994 1
995 1 uint cycle2=0;//通道2的平均周期
996 1 uint thousand=0;//显示数字时用
997 1 uint hundred=0;
998 1 uint t=0;//计算用的临时变量
999 1 uint total=0;
1000 1
1001 1 uchar ten=0;
1002 1 uchar one=0;
1003 1 bit time=0;
1004 1
1005 1 bit oper=0;
1006 1 bit finish=0;
1007 1
1008 1 char i=0;
1009 1
1010 1 uchar pointer=0;
1011 1 uchar *p=&result;//写一个数组result[]进入24C08
1012 1
1013 1 TMOD=0x21;//定时器1,方式2,常数自动装入的8位定时器;定时器0工作在方式1,为16位定时器
1014 1
1015 1 IE=0x80;//定时器0,1;中断0,1全部开
1016 1 IT0=1;//均下降沿触发
1017 1 IT1=1;
1018 1
1019 1 PCON=0x80;//SMOD=1,串行口波特率加倍
1020 1 SCON=0xd0;//串行口工作在方式3
1021 1
1022 1 TH1=0xf3;//12M晶振下4800的波特率
1023 1 TL1=0xf3;
1024 1
1025 1 TH0=-(1244/256);//定时器0置初值
1026 1 TL0=-(1244%256);
1027 1
1028 1 TR1=1;
1029 1
1030 1 clear();
1031 1 dison_off(1);
1032 1 for(i=0;i<64;i++)
1033 1 {
1034 2 for(total=0;total<8;total++)
1035 2 {
1036 3 setadr(total,i);
1037 3 wdata(hui[i+64*total],1,0);
1038 3 }
1039 2 delay(700);
1040 2 }
1041 1 total=0;
1042 1 print2(dong,2,64);
1043 1 print2(nan,2,16+64);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -