在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<s id="cmphk"><label id="cmphk"></label></s>
    <span id="cmphk"><var id="cmphk"></var></span>
    <dfn id="cmphk"><var id="cmphk"></var></dfn>
    <menu id="cmphk"><thead id="cmphk"></thead></menu>

    <address id="cmphk"></address>

      <dfn id="cmphk"></dfn>
      
      
      <span id="cmphk"></span>

      <object id="cmphk"><tt id="cmphk"></tt></object>
      1. 新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 1602控制forMSP430

        1602控制forMSP430

        作者: 時間:2016-11-27 來源:網(wǎng)絡 收藏
      2. /*************************************************************************
      3. //名稱:LocateXY
      4. //參數(shù):unsignedcharx,unsignedchary
      5. //返回值:無
      6. //功能:確定1602寫入數(shù)據(jù)的位置,X為行坐標,Y為列坐標(都從0開始)
      7. *************************************************************************/
      8. voidLocateXY(ucharx,uchary)
      9. {
      10. uchartemp;
      11. temp=x&0x0f;
      12. y&=0x01;
      13. if(y)temp|=0x40;//如果在第2行
      14. temp|=0x80;
      15. WriteCommand(temp,1);
      16. }
      17. /*************************************************************************
      18. //名稱:LcdInit
      19. //參數(shù):無
      20. //返回值:無
      21. //功能:1602初始化
      22. *************************************************************************/
      23. voidLcdInit(void)
      24. {
      25. CtrlDir|=0x07;//控制線端口設為輸出狀態(tài)
      26. DataDir|=0xFF;//數(shù)據(jù)端口設為輸出狀態(tài)
      27. WriteCommand(0x38,0);//規(guī)定的復位操作
      28. Delay5ms();
      29. WriteCommand(0x38,0);
      30. Delay5ms();
      31. WriteCommand(0x38,0);
      32. Delay5ms();
      33. WriteCommand(0x38,1);//顯示模式設置
      34. WriteCommand(0x08,1);//顯示關閉
      35. WriteCommand(0x01,1);//顯示清屏
      36. WriteCommand(0x06,1);//寫字符時整體不移動
      37. WriteCommand(0x0c,1);//顯示開,不開游標,不閃爍
      38. }
      39. /*************************************************************************
      40. //名稱:WriteStr
      41. //參數(shù):待寫入數(shù)組的首地址,unsignedintn,unsignedcharx,unsignedchary
      42. //返回值:無
      43. //功能:在給定位置顯示一個數(shù)組,長度為l
      44. *************************************************************************/
      45. voidWriteStr(uchar*a,uintl,ucharx,uchary)
      46. {
      47. uchari;
      48. LocateXY(x,y);
      49. for(i=0;i
      50. WriteData(a[i]);
      51. }
      52. /*************************************************************************
      53. //名稱:WriteNum
      54. //參數(shù):待寫入數(shù)字,unsignedcharx,unsignedchary
      55. //返回值:無
      56. //功能:在給定位置顯示一個數(shù)字(不超過5位且小于65536)
      57. *************************************************************************/
      58. voidWriteNum(uintn,ucharx,uchary)
      59. {
      60. ucharfive,four,three,two,one;
      61. LocateXY(x,y);
      62. if((n>=10000)&&(n<=65535))
      63. {
      64. five=n/10000;
      65. four=(n%10000)/1000;
      66. three=((n-five*10000)%1000)/100;
      67. two=((n-five*10000)%1000-three*100)/10;
      68. one=((n-five*10000)%1000-three*100)%10;
      69. WriteData(NUM[five]);
      70. WriteData(NUM[four]);
      71. WriteData(NUM[three]);
      72. WriteData(NUM[two]);
      73. WriteData(NUM[one]);
      74. }
      75. if((n>=1000)&&(n<=9999))
      76. {
      77. four=n/1000;
      78. three=(n%1000)/100;
      79. two=(n%1000-three*100)/10;
      80. one=(n%1000-three*100)%10;
      81. WriteData(NUM[four]);
      82. WriteData(NUM[three]);
      83. WriteData(NUM[two]);
      84. WriteData(NUM[one]);
      85. }
      86. if((n>=100)&&(n<=999))
      87. {
      88. three=n/100;
      89. two=(n-three*100)/10;
      90. one=(n-three*100)%10;
      91. WriteData(NUM[three]);
      92. WriteData(NUM[two]);
      93. WriteData(NUM[one]);
      94. }
      95. if((n>=10)&&(n<=99))
      96. {
      97. two=n/10;
      98. one=n%10;
      99. WriteData(NUM[two]);
      100. WriteData(NUM[one]);
      101. }
      102. if((n>0)&&(n<=9))WriteData(NUM[n]);
      103. }
      104. /*************************************************************************
      105. //名稱:WriteFloat
      106. //參數(shù):待寫入浮點數(shù),unsignedcharx,unsignedchary
      107. //返回值:無
      108. //功能:在給定位置顯示一個浮點數(shù)(整數(shù)部分和小數(shù)部分都不超過兩位)
      109. *************************************************************************/
      110. voidWriteFloat(floatn,ucharx,uchary)
      111. {
      112. uintInteger,Decimal;//Integer用于存放整數(shù)部分,Decimal用于存放小數(shù)部分
      113. Integer=(uint)(n/1);
      114. Decimal=(uint)(n*100-Integer*100);
      115. WriteNum(Integer,x,y);
      116. WriteData(NUM[10]);
      117. WriteNum(Decimal,x+3,y);
      118. }


      119. 上一頁 1 2 下一頁

        關鍵詞: 1602控制MSP43

        評論


        相關推薦

        技術專區(qū)

        關閉