<strong id="0toem"><dl id="0toem"></dl></strong><b id="0toem"><menuitem id="0toem"></menuitem></b>

      <b id="0toem"><menuitem id="0toem"></menuitem></b>
    1. <code id="0toem"><abbr id="0toem"></abbr></code>
      <strong id="0toem"><dl id="0toem"></dl></strong>
      <kbd id="0toem"></kbd>
              1. <code id="0toem"></code>
                <th id="0toem"><progress id="0toem"></progress></th><strong id="0toem"><form id="0toem"></form></strong>

                <th id="0toem"></th>
              2. 131 1300 0010
                其他
                當前位置: 首頁>> 元件技術(shù)>>其他>>
              3. 導(dǎo)航欄目
              4. 二極管
              5. 整流橋
              6. MOS管
              7. 其他
              8. 51單片機的數(shù)值寫入方法介紹
                51單片機的數(shù)值寫入方法介紹
              9. 51單片機的數(shù)值寫入方法介紹
              10.   發(fā)布日期: 2019-03-23  瀏覽次數(shù): 1,708

                1.在MCU中都是以二進制的形式進行計算的。

                2.在編程時,我們通常用到的有十進制的數(shù)值形式和十六進制的數(shù)值形式,如52,0xfe;

                 

                3.數(shù)值的大小由數(shù)據(jù)的類型來決定。

                4.常用的有“unsigned int”和“unsigned char”。

                “unsigned char”的范圍是“0-255”, 與單片機端口的8位的最大值(0xff)相對應(yīng)。

                “unsigned int”的范圍是“0-65535”,與之對應(yīng)的是“0xffff”。

                51單片機的數(shù)值寫入方法介紹
                 

                5.數(shù)值的寫入:

                在51單片機中,寫入的數(shù)值可以是十進制和十六進制,但不能是二進制。

                比如:P1=4; P1=0X04;

                當寫語句“P1=4;”時

                P1^0——P1^7的電平依次為 “0010 0000”

                當寫語句“P1=65;”時

                P1^0——P1^7的電平依次為 “1000 0010”; 65的十六進制碼為:0x41

                從以上兩個數(shù)值可以發(fā)現(xiàn),端口的低位對應(yīng)的是數(shù)值的低位,端口的高位對應(yīng)的是數(shù)值的高位。

                6.在用數(shù)碼管顯示數(shù)字的時候,是一個位數(shù)字,一位數(shù)字的寫入,比如說26,先寫2,再寫6.

                以用數(shù)碼管寫2為例:將數(shù)碼管的斷選abcdefgdp分別接到P1^0,P1^1……P1^7;

                若要顯示2,則要求abcdefgdp依次為:1101 1010

                如果按照端口的對應(yīng),寫P1=0xda,那就錯了。

                二進制也是高位在前,低位在后,所以端口寫數(shù)據(jù)時也要低對低,高對高,所以要將“1101 1010”為

                “0101 1011”

                所以數(shù)碼管顯示2的十六進制碼為“P1=0x5b”

                同理可算出“0-9”的十六進制碼依次為“0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f”


              11. ·上一篇:
                ·下一篇:
              12. 其他關(guān)聯(lián)資訊
                深圳市日月辰科技有限公司
                地址:深圳市寶安區(qū)松崗鎮(zhèn)潭頭第二工業(yè)城A區(qū)27棟3樓
                電話:0755-2955 6626
                傳真:0755-2978 1585
                手機:131 1300 0010
                郵箱:[email protected]

                深圳市日月辰科技有限公司 版權(quán)所有:Copyright?2010-2023 www.xydibang.com 電話:13113000010 粵ICP備2021111333號
                <strong id="0toem"><dl id="0toem"></dl></strong><b id="0toem"><menuitem id="0toem"></menuitem></b>

                    <b id="0toem"><menuitem id="0toem"></menuitem></b>
                  1. <code id="0toem"><abbr id="0toem"></abbr></code>
                    <strong id="0toem"><dl id="0toem"></dl></strong>
                    <kbd id="0toem"></kbd>
                            1. <code id="0toem"></code>
                              <th id="0toem"><progress id="0toem"></progress></th><strong id="0toem"><form id="0toem"></form></strong>

                              <th id="0toem"></th>
                            2. 午夜免费无码视频 | 久久中文综合网 | 欧美,日韩,另类,日韩 | 九九精品成人 | 四虎久久|