標(biāo)題: 51單片機(jī)學(xué)習(xí)串口功能切換問題 [打印本頁]

作者: 有牽掛才會怕    時(shí)間: 2018-1-9 11:24
標(biāo)題: 51單片機(jī)學(xué)習(xí)串口功能切換問題
請各位大神幫我看看,我在做51單片機(jī)的功能,通過串口助手輸入1、2都有功能,但是無法相互切換,我經(jīng)驗(yàn)不足代碼不知道應(yīng)該怎么修改,求各位幫幫忙!

  1. #include <reg51.h>
  2. #include <intrins.h>
  3. #include <absacc.h>
  4. #include "LCD1602.h"
  5. #include "keyword.h"
  6. #include "ds18b20.h"
  7. #include "liushuideng.h"
  8. #include "0832.h"
  9. #include "12864.h"
  10. #include "1302.h"
  11. #include "lcd12864.h"
  12. #include "DS1302.h"

  13. #define uchar unsigned char
  14. #define uint unsigned int

  15. uchar zhi;

  16. void zhongduan()
  17. {
  18.         SCON=0x50;
  19.         TMOD=0x20;
  20.         TH1=0xfd;
  21.         TL1=0xfd;
  22.         IE=0x90;
  23.         TR1=1;
  24. }

  25. void liushuiinit()
  26. {
  27.         COM = 0x90;
  28.         PA = 0xff;
  29.         PB = 0xff;
  30.         PC = 0xff;
  31. }

  32. void main()
  33. {
  34.         zhongduan();
  35.        
  36.         while(1)
  37.         {
  38.                 if(zhi==1)
  39.                 {
  40.                         Init_LCD1602();
  41.                         while(1)
  42.                         {
  43.                                 jisuanqi();
  44.                                 if(zhi!=1)
  45.                                 {
  46.                                         break;
  47.                                 }       
  48.                         }       
  49.                 }
  50.                 else if(zhi==2)
  51.                 {
  52.                         liushuiinit();
  53.                         while(1)
  54.                         {
  55.                                 liushuideng();
  56.                                 if(zhi!=2)
  57.                                 {
  58.                                         PB=0XFF;
  59.                                         break;
  60.                                 }       
  61.                         }
  62.                 }
  63.                 else if(zhi==3)
  64.                 {
  65.                         while(1)
  66.                         {
  67.                                 m_12864();
  68.                                 if(zhi!=3)
  69.                                 {
  70.                                         break;
  71.                                 }
  72.                         }
  73.                 }               
  74.         }
  75. }
  76.          

  77.         //Init_LCD1602();
  78.         //jisuanqi();
  79.         //DS18B20();
  80.         //liushuideng();
  81.         //m_0832();
  82.         //m_12864();
  83.         //m_1302();

  84. void intser() interrupt 4
  85. {
  86.         RI=0;
  87.         zhi=SBUF;
  88. }
復(fù)制代碼








歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1