芯片解密|单片机解密|IC解密|芯片破解|芯片复制| PCB抄板|软件开发

飞芯科技-芯片解密|单片机解密|IC解密|芯片破解|芯片复制| PCB抄板|软件开发

STC15w4k58s4单片机4串口同时收发例程IC解密

IC解密单片机源程序如下:

  1. #include "intrins.H"
  2. #include "uart.H"
  3. #define uchar unsigned  char
  4. #define uint  unsigned   int

  5. uchar uart1buf[6]={0xa5,0x5a,0x4a,0xf8,0xff,0xff};
  6. uchar uart2buf[6]={0xa5,0x5a,0x4a,0xf8,0xff,0xff};
  7. uchar uart3buf[6]={0xa5,0x5a,0x4a,0xf8,0xff,0xff};
  8. uchar uart4buf[6]={0xa5,0x5a,0x4a,0xf8,0xff,0xff};
  9. uchar uart2_i,uart3_i,uart4_i;
  10. bit flag2=0,flag3=0,flag4=0;         //flag of reveived new packs  收到新数据包标志
  11. void delay(uint k)       
  12. {                                               
  13. uint i,j;                               
  14. for(i=0;i<k;i++)
  15. {                       
  16. for(j=0;j<121;j++)                       
  17. {;}}                                               
  18. }
  19. void main()
  20. {
  21. uchar i;
  22. uint l1,l2,l3;
  23. Uart1Init();
  24. Uart2Init();
  25. Uart3Init();
  26. Uart4Init();
  27. while(1)
  28. {
  29.   if(flag3==1||flag2==1||flag4==1)
  30.   {
  31.    flag4=0;
  32.    flag3=0;
  33.    flag2=0;
  34.    for(i=0;i<6;i++)
  35.    uart1buf[i]=uart3buf[i];
  36.    l1=256*uart2buf[2]+uart2buf[3];
  37.    l1=l1/10*7;
  38.    l2=256*uart3buf[2]+uart3buf[3];
  39.    l2=l2/10*7;
  40.    l3=256*uart4buf[2]+uart4buf[3];
  41.    if(l1<=l2&&l1<=l3)
  42.    {
  43.    uart1buf[2]=l1/256;
  44.    uart1buf[3]=l1%256;
  45.    }
  46.    if(l2<=l1&&l2<=l3)
  47.    {
  48.    uart1buf[2]=l2/256;
  49.    uart1buf[3]=l2%256;
  50.    }
  51.    if(l3<=l1&&l3<=l2)
  52.    {
  53.    uart1buf[2]=uart4buf[2];
  54.    uart1buf[3]=uart4buf[3];   
  55.    }
  56.    if(uart1buf[2]>=0xea)
  57.    {
  58.    uart1buf[2]=0xea;
  59.    uart1buf[3]=0x00;
  60.    }
  61.    for(i=0;i<6;i++)
  62.    UART1_SendData(uart1buf[i]);
  63.   }
  64. //   delay(500);
  65. }
  66. }

  67. void Uart2() interrupt 8 using 1
  68. {
  69.     if (S2CON & S2RI)
  70.     {
  71.         S2CON &= ~S2RI;         //清除S2RI位
  72.                 uart2buf[uart2_i]=S2BUF;
  73.                 uart2_i++;
  74.                 if(uart2_i==6)
  75.                 {
  76.                 uart2_i=0;
  77.                 flag2=1;
  78.                 if(uart2buf[2]==0&&uart2buf[3]==0)
  79.                 {
  80.                  uart2buf[2]==0x2a;
  81.                  uart2buf[3]==0xf8;
  82.                 }
  83.                 }
  84.     }
  85.     if (S2CON & S2TI)
  86.     {
  87.         S2CON &= ~S2TI;         //清除S2TI位
  88.     }
  89. }
  90. void Uart3() interrupt 17 using 1
  91. {
  92.     if (S3CON & S3RI)
  93.     {
  94.         S3CON &= ~S3RI;         //清除S2RI位
  95.                 uart3buf[uart3_i]=S3BUF;
  96.                 uart3_i++;
  97.                 if(uart3_i==6)
  98.                 {
  99.                 uart3_i=0;
  100.                 flag3=1;
  101.                 if(uart3buf[2]==0&&uart3buf[3]==0)
  102.                 {
  103.                  uart3buf[2]==0x2a;
  104.                  uart3buf[3]==0xf8;
  105.                 }
  106.                 }
  107.     }
  108.     if (S3CON & S3TI)
  109.     {
  110.         S3CON &= ~S3TI;         //清除S3TI位
  111.     }
  112. }
  113. void Uart4() interrupt 18 using 1
  114. {
  115.     if (S4CON & S4RI)
  116.     {
  117.         S4CON &= ~S4RI;         //清除S2RI位
  118.                 uart4buf[uart4_i]=S4BUF;
  119. ……………………



联系方式

地址:石家庄市新华区民族路77号华强广场D座2009
电话:0311-88816616/87087811
手机:13315190088
传真:0311-67901001
联系人:张工
网址:www.feixindz.com
邮箱:feixindz@163.com
微信:xinpianjiemi
QQ:527263666/568069805

在线客服
热线电话

企业微信