找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2276|回复: 2
打印 上一主题 下一主题
收起左侧

stm32f103c6使用三片74HC595级联程序代码Proteus仿真原理图

[复制链接]
跳转到指定楼层
楼主
仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)


单片机源程序如下:
  1. //实验现象:3位数码管轮流显示数码管编码表里面的字符
  2. #include "led.h"
  3. #include "delay.h"
  4. #include "sys.h"
  5. #include "HC595.h"

  6. unsigned char Qian_Wei,Bai_Wei,Shi_Wei,Ge_Wei;        //千位,百位,十位,个位

  7. //数码管编码
  8. unsigned char table[] =
  9. {0xc0,0xf9,0xa4,0xb0,0x99,
  10. 0x92,0x82,0xf8,0x80,0x90,
  11. 0xff,0x00,0x90,0x86,0xaf,
  12. 0xc0,0x89,0xc7,0x8e,0xc1,0x7f};
  13. //0,1,2,3,4,5,6,7,8,9,全暗,全亮,g,E,r,O,H,L,F,U,小数点,共阳数码管使用


  14. int main(void)
  15. {
  16.         int a, b, c, d;
  17.         a = 0;//这些常量置0,否则后面显示会出问题
  18.         b = 0;
  19.         c = 0;
  20.         d = 0;
  21.         SystemInit();                                        //系统时钟初始化为72M          SYSCLK_FREQ_72MHz
  22.         delay_init(72);                                //延时函数初始化
  23.         NVIC_Configuration();        //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
  24.         LED_Init();                                                //LED端口初始化
  25.         HC595_Init();
  26.        
  27.         //清空LED数码管
  28.         Bai_Wei = table[10];//清空LED
  29.         Shi_Wei = table[10];//清空LED
  30.         Ge_Wei = table[10];//清空LED
  31.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  32.         delay_ms(3000);
  33.        
  34.         //依次测试百位至个位全亮
  35.         Bai_Wei = table[11];//百位全亮
  36.         Shi_Wei = table[10];//清空LED
  37.         Ge_Wei = table[10];//清空LED
  38.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  39.         delay_ms(2000);
  40.         Bai_Wei = table[10];//清空LED
  41.         Shi_Wei = table[11];//十位全亮
  42.         Ge_Wei = table[10];//清空LED
  43.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  44.         delay_ms(2000);
  45.         Bai_Wei = table[10];//清空LED
  46.         Shi_Wei = table[10];//清空LED
  47.         Ge_Wei = table[11];//个位全亮
  48.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  49.         delay_ms(2000);
  50.        
  51.         //同时显示0~9
  52.         Bai_Wei = table[0];
  53.         Shi_Wei = table[0];
  54.         Ge_Wei = table[0];
  55.         HC595_Display(Bai_Wei, Shi_Wei, Ge_Wei);
  56.         delay_ms(2000);
  57.         Bai_Wei = table[1];
  58.         Shi_Wei = table[1];
  59.         Ge_Wei = table[1];
  60.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  61.         delay_ms(2000);
  62.         Bai_Wei = table[2];
  63.         Shi_Wei = table[2];
  64.         Ge_Wei = table[2];
  65.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  66.         delay_ms(2000);
  67.         Bai_Wei = table[3];
  68.         Shi_Wei = table[3];
  69.         Ge_Wei = table[3];
  70.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  71.         delay_ms(2000);
  72.         Bai_Wei = table[4];
  73.         Shi_Wei = table[4];
  74.         Ge_Wei = table[4];
  75.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  76.         delay_ms(2000);
  77.         Bai_Wei = table[5];
  78.         Shi_Wei = table[5];
  79.         Ge_Wei = table[5];
  80.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  81.         delay_ms(2000);
  82.         Bai_Wei = table[6];
  83.         Shi_Wei = table[6];
  84.         Ge_Wei = table[6];
  85.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  86.         delay_ms(2000);
  87.         Bai_Wei = table[7];
  88.         Shi_Wei = table[7];
  89.         Ge_Wei = table[7];
  90.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  91.         delay_ms(2000);
  92.         Bai_Wei = table[8];
  93.         Shi_Wei = table[8];
  94.         Ge_Wei = table[8];
  95.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  96.         delay_ms(2000);
  97.         Bai_Wei = table[9];
  98.         Shi_Wei = table[9];
  99.         Ge_Wei = table[9];
  100.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  101.         delay_ms(2000);
  102.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  103.         delay_ms(2000);
  104.        
  105.         while(1)
  106.         {               
  107.                 LED0=0;                                                        //这里使用了位带操作,也可以使用 GPIO_ResetBits(GPIOA,GPIO_Pin_8);
  108.                 delay_ms(20);                 
  109.                 LED0=1;                                                        //也可以使用          GPIO_SetBits(GPIOA,GPIO_Pin_8);                           
  110.                 delay_ms(20);                       

  111.                 a++;
  112.                 if(a==1)
  113.                 {
  114.                         a = 0;
  115.                         b++;
  116.                 }
  117.                 if(b == 10)
  118.                 {
  119.                         b = 0;
  120.                          c++;
  121.                 }
  122.                 if(c == 10)
  123.                 {
  124.                         c = 0;
  125.                         d++;                       
  126.                 }
  127.                 if(d == 10)d= 0;
  128.                 Bai_Wei = table[d];
  129.                 Shi_Wei = table[c];
  130.                 Ge_Wei = table[b];
  131.                 HC595_Display(Bai_Wei,Shi_Wei,Ge_Wei);
  132.                 //delay_ms(100);
  133.         }
  134. }
复制代码

所有资料51hei附件下载:
代码: STM32F103C6.7z (179.12 KB, 下载次数: 86)
仿真: protues.zip (65.16 KB, 下载次数: 68)


评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏3 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:619071 发表于 2022-2-6 21:58 | 只看该作者
想问一下,我的是proteus8.9 里面搜不到STM32的MCU,应该怎么操作啊
回复

使用道具 举报

板凳
ID:928738 发表于 2022-2-10 11:20 | 只看该作者
lishuo123 发表于 2022-2-6 21:58
想问一下,我的是proteus8.9 里面搜不到STM32的MCU,应该怎么操作啊

我protues8.0就可以,你是不是库没装好?安装要联网
回复

使用道具 举报

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

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表