新聞中心

        EEPW首頁 > 嵌入式系統 > 設計應用 > 數字電路中Multisim10單片機的應用

        數字電路中Multisim10單片機的應用

        作者: 時間:2011-09-21 來源:網絡 收藏
        2 編寫MCU源C語言程序

        本文引用地址:http://www.104case.com/article/172489.htm

          2. 1 雙擊“設計工具盒”中的源文件“Led11. c”,在其右側將打開編寫程序窗口,刪除已有的文字注釋說明。

          2. 2 在源程序窗口輸入以下11進制計數器C語言源程序:

          #include htc. h

          void delay( unsigned int i) ;

          unsigned char code table [ ] = { 0x40, 0x79, 0x24, 0x30, 0x19, 0x12, 0x02,

          0x78, 0x00, 0x90};

          unsigned char a1, a2, a3;

          void main ( )

          {

          unsigned int i;

          while (1)

          { for( i = 0; i 11; i + + )

          {

          if ( i = = 0)

          {P2 = 0x40;

          P1 = 0x40;

          P0 = 0x40; }

          if ( i = = 1)

          {P2 = 0x79;

          P1 = 0x40;

          P0 = 0x40; }

          if ( i = = 2)

          {P2 = 0x24;

          P1 = 0x40;

          P0 = 0x40;

          }

          if ( i = = 3)

          {

          P2 = 0x30;

          P1 = 0x40;

          P0 = 0x40;

          }

          if ( i = = 4)

          {

          P2 = 0x19;

          P1 = 0x40;

          P0 = 0x40;

          }

          if ( i = = 5)

          {


        P2 = 0x12;

          P1 = 0x40;

          P0 = 0x40;

          }

          if ( i = = 6)

          {

          P2 = 0x02;

          P1 = 0x40;

          P0 = 0x40;

          }

          if ( i = = 7)

          {

          P2 = 0x78;

          P1 = 0x40;

          P0 = 0x40;

          }

          if ( i = = 8)

          {

          P2 = 0x00;

          P1 = 0x40;

          P0 = 0x40;

          }

          if ( i = = 9)

          {

          P2 = 0x10;

          P1 = 0x40;

          P0 = 0x40;

          }

          if ( i = = 10)

          {

          P2 = 0x40;

          P1 = 0x79;

          P0 = 0x40;

          i = 0;

          }

          }

          } }

          void delay( unsigned int i)

          {

          while ( i - - ) ;

          }

        DIY機械鍵盤相關社區:機械鍵盤DIY




        評論


        相關推薦

        技術專區

        關閉
        主站蜘蛛池模板: 十堰市| 烟台市| 延安市| 蛟河市| 五寨县| 桃园县| 抚远县| 宝坻区| 巴里| 武邑县| 扶沟县| 蕉岭县| 军事| 星座| 平阳县| 青阳县| 沂源县| 蒲江县| 花垣县| 若尔盖县| 泸州市| 龙州县| 鄂州市| 安仁县| 大冶市| 大兴区| 东乡族自治县| 商丘市| 阿巴嘎旗| 怀仁县| 芦溪县| 临洮县| 汉中市| 调兵山市| 中江县| 龙陵县| 阿瓦提县| 句容市| 松滋市| 万载县| 新泰市|