首 页文档资料下载资料维修视频包年699元
请登录  |  免费注册
当前位置:精通维修下载 > 文档资料 > 家电技术 > 单元电路介绍 > 其它电路
数字电路中Multisim10单片机的应用
来源:本站整理  作者:佚名  2011-09-23 10:35:08



2 编写MCU源C语言程序

  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 - - ) ;

  }

上一页  [1] [2] [3]  下一页

关键词:

文章评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分)
Copyright © 2007-2017 down.gzweix.Com. All Rights Reserved .
页面执行时间:176,210.90000 毫秒