[Atmel] 用AtmelStudio6.2跑mega16例程(29)依次显示数字

[复制链接]
 楼主| ddllxxrr 发表于 2014-10-7 19:55 | 显示全部楼层 |阅读模式
这个程序依次显示0-7,其中,一个管脚点亮显示,一个管脚送显示的字模。

显示管用的是proteus的SEG_MPX8_CA_BLUE  CA共阳common Anode CC共阴common catnode

程序如下:

  1. #define F_CPU 8000000UL
  2. #include <avr/io.h>
  3. #include <util/delay.h>
  4. #include <stdint.h>

  5. const uint8_t SEG_CODE[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};

  6. int main(void)
  7. {
  8.     uint8_t i;
  9.         DDRC = 0xFF;
  10.         DDRD = 0xFF;
  11.         while(1)
  12.     {
  13.          for(i=0;i<8;i++)
  14.                  {
  15.                  PORTD=_BV(i);
  16.                  PORTC= SEG_CODE[i];
  17.                  _delay_ms(40);
  18.                  }
  19.     }
  20. }
Proteus 仿真如下:


Studio 6.2 编译截图:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:http://shop34182318.taobao.com/ http://shop562064536.taobao.com

2403

主题

6994

帖子

68

粉丝
快速回复 在线客服 返回列表 返回顶部
个人签名:http://shop34182318.taobao.com/ http://shop562064536.taobao.com

2403

主题

6994

帖子

68

粉丝
快速回复 在线客服 返回列表 返回顶部