欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標(biāo)題: 請問一下我的這個s4單片機(jī)編譯的程序?yàn)槭裁闯霈F(xiàn)這種錯誤?error C141: syntax error... [打印本頁]

作者: suning    時間: 2021-11-21 15:17
標(biāo)題: 請問一下我的這個s4單片機(jī)編譯的程序?yàn)槭裁闯霈F(xiàn)這種錯誤?error C141: syntax error...
錯誤是:
PCI協(xié)議.C(75): error C141: syntax error near '|'
PCI協(xié)議.C(103): error C141: syntax error near ';'
PCI協(xié)議.C(103): error C141: syntax error near ')'
PCI協(xié)議.C(104): error C141: syntax error near '|'

這個程序是要實(shí)現(xiàn)一次SPI協(xié)議,各種方法都試了就是解決不了這個問題。
我在c++里都試了一遍,可以通過。

單片機(jī)源程序如下:
  1. #include<reg51.h>
  2. #define MASTER
  3. typedef unsigned int u8;
  4. typedef unsigned char u16;
  5. typedef unsigned long int u32;

  6. #define URMD 0
  7. sfr T2H=0XD6;
  8. sfr T2L=0XD7;

  9. sfr AUXR=0X8E;
  10. sfr SPSTAT=0Xcd;
  11. #define SPIF 0X80;
  12. #define WCOL 0X40;                  
  13. sfr SPCTL=0XCE;
  14. #define        SSIG 0X80
  15. #define        SPEN 0X40
  16. #define        DORD 0X20
  17. #define        MSTR 0X10
  18. #define        CPOL 0X08
  19. #define        CPHA 0X04
  20. #define        SPDHH 0X00
  21. #define        SPDH 0X01
  22. #define        SPDL 0X02
  23. #define        SPDLL 0X03
  24. sbit SPISS=P1^1;
  25. sfr SPDAT=0XCF;

  26. #define ESPI 0X02

  27. void SendUart(u16 dat);
  28. void InitUart();
  29. void InitSPI();
  30. u16 RecvUart();
  31. u16 SPISwap(u16 dat);
  32. void main()
  33. {
  34.    InitUart();
  35.    InitSPI();
  36.    while(1)
  37.    {
  38.       #ifdef MASTER
  39.          SendUart(SPISwap(RecvUart()));
  40.           #else
  41.           ACC=SPISwap(ACC);
  42.           #endif
  43.         }
  44. }

  45. void InitUart()
  46. {
  47.      SCON=0X5A;
  48. #if         URMD==0
  49.      T2L=0XD8;
  50.          T2H=0XFF;
  51.          AUXR=0X14;
  52.          AUXR|=0X01;
  53. #elif URMD==1
  54.       AUXR=0X40;
  55.           TMOD=0X00;
  56.           TL1=0XD8;
  57.           TH1=0XFF;
  58.           TR1=1;
  59. #else
  60.       TMOD=0X20;
  61.           AUXR=0X40;
  62.           TH1=TL1=0XFB;
  63.           TR1=1;
  64. #endif
  65. }

  66. void InitSPI()
  67. {
  68.     SPDAT=0;
  69.         SPSTAT=SPIF|WCOL;
  70. #ifdef MASTER
  71.     SPCTL=SPEN|MSTR;
  72. #else
  73.     SPCTL=SPEN;
  74. #endif
  75. }

  76. void SendUart(u16 dat)
  77. {
  78.     while(!TI)
  79.         TI=0;
  80.         SBUF=dat;
  81.         }

  82. u16 RecvUart()
  83. {        
  84.     while(!RI)
  85.         RI=0;
  86.         return SBUF;
  87.         }

  88. u16 SPISswap(u16 dat)
  89. {
  90.   #ifdef MASTER
  91.   SPISS=0;
  92.   #endif
  93.    SPDAT=dat;
  94.   while(!(SPSTAT&SPIF))
  95.    SPSTAT=SPIF|WCOL;
  96.   #ifdef MASTER
  97.   SPISS=1;
  98.   #endif
  99.    return SPDAT;
  100. }
復(fù)制代碼

作者: 小黑屋525    時間: 2021-11-22 11:04
語法錯誤啊,,,,在75行和104行,把這兩行改成SPSTAT=(SPIF|WCOL);這樣子試試。




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