当前位置:网站首页>STM32扩展板 数码管显示
STM32扩展板 数码管显示
2022-07-01 04:40:00 【花开半朵ོ】
先看原理图


数码管是由74HC595驱动的。

14脚:DS:串行数据输入引脚
13脚:OE:输出使能控制脚,低电平使能输出,所以接地
12脚:ST_CP(RCK):存储器存储时钟引脚,上升沿时,数据从移位寄存器转存到存储寄存器
11脚:SH_CP(SCK):移位寄存器时钟引脚,上升沿时,移位寄存器中的数据整体后移,并接受新的数据(从DS输入)
10脚:MR:低电平有效,清空移位寄存器中已有的数据,一般不用,接高电平即可
9脚:Q7’:串行数据输出,级联输出端,接下一个595的DS端(当移位寄存器中的数据多于8位,会把已有的位“挤出去”)
1-7脚,15脚:并行输出引脚
seg.c
#include "seg.h"
uint8_t seg_table[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00};
void DisplayValue(uint8_t value1,uint8_t value2,uint8_t value3)
{
uint8_t i = 0;
uint8_t value = 0;
RCLK_L; //ST_CP
value = seg_table[value3];
for(i = 0; i < 8; i++)
{
SCK_L;//SH_CP
if(value & 0x80)
{
SER_H;//DS
}
else
{
SER_L;
}
value <<= 1;
SCK_H;
}
value = seg_table[value2];
for(i = 0; i < 8; i++)
{
SCK_L;
if(value & 0x80)
{
SER_H;
}
else
{
SER_L;
}
value <<= 1;
SCK_H;
}
value = seg_table[value1];
for(i = 0; i < 8; i++)
{
SCK_L;
if(value & 0x80)
{
SER_H;
}
else
{
SER_L;
}
value <<= 1;
SCK_H;
}
RCLK_H;
}
seg.h
#ifndef _SEG_H_
#define _SEG_H_
#include "main.h"
#define RCLK_PIN GPIO_PIN_2
#define RCLK_PORT GPIOA
#define SER_PIN GPIO_PIN_1
#define SER_PORT GPIOA
#define SCK_PIN GPIO_PIN_3
#define SCK_PORT GPIOA
#define RCLK_H HAL_GPIO_WritePin(RCLK_PORT,RCLK_PIN,GPIO_PIN_SET);
#define RCLK_L HAL_GPIO_WritePin(RCLK_PORT,RCLK_PIN,GPIO_PIN_RESET);
#define SER_H HAL_GPIO_WritePin(SER_PORT,SER_PIN,GPIO_PIN_SET);
#define SER_L HAL_GPIO_WritePin(SER_PORT,SER_PIN,GPIO_PIN_RESET);
#define SCK_H HAL_GPIO_WritePin(SCK_PORT,SCK_PIN,GPIO_PIN_SET);
#define SCK_L HAL_GPIO_WritePin(SCK_PORT,SCK_PIN,GPIO_PIN_RESET);
void DisplayValue(uint8_t value1,uint8_t value2,uint8_t value3);
#endif
边栏推荐
- [ue4] event distribution mechanism of reflective event distributor and active call event mechanism
- CUDA development and debugging tool
- LM small programmable controller software (based on CoDeSys) note 19: errors do not match the profile of the target
- Execution failed for task ‘:app:processDebugResources‘. > A failure occurred while executing com. and
- selenium打开chrome浏览器时弹出设置页面:Mircrosoft Defender 防病毒要重置您的设置
- 2022 question bank and answers for safety production management personnel of hazardous chemical production units
- MySQL advanced -- you will have a new understanding of MySQL
- 如何看待智慧城市建设中的改变和机遇?
- Grey correlation cases and codes
- TCP/IP 详解(第 2 版) 笔记 / 3 链路层 / 3.4 桥接器与交换机 / 3.4.2 多属性注册协议(Multiple Registration Protocol (MRP))
猜你喜欢

扩展-Fragment
![[godot] unity's animator is different from Godot's animplayer](/img/51/48f40a7b6736d7f78040eabbbd3395.jpg)
[godot] unity's animator is different from Godot's animplayer

TCP server communication flow

JS image path conversion Base64 format

无器械健身
![[pat (basic level) practice] - [simple simulation] 1064 friends](/img/37/0ef0f8aae15ae574be1d76c97497c9.jpg)
[pat (basic level) practice] - [simple simulation] 1064 friends

Question bank and online simulation examination for special operation certificate of G1 industrial boiler stoker in 2022

LM小型可编程控制器软件(基于CoDeSys)笔记十九:报错does not match the profile of the target

VIM easy to use tutorial

Grey correlation cases and codes
随机推荐
MySQL advanced -- you will have a new understanding of MySQL
解决qiankun中子应用外链文件无法获取
Leecode question brushing record 1310 subarray XOR query
2022-02-15 (399. Division evaluation)
数据加载及预处理
CUDA development and debugging tool
网站服务器:好用的网站服务器怎么选这五方面要关注
2022 G2 power station boiler stoker examination question bank and G2 power station boiler stoker simulation examination question bank
Common interview questions ①
Pytorch(三) —— 函数优化
Maixll dock quick start
2022.2.7-2.13 AI industry weekly (issue 84): family responsibilities
2022 a special equipment related management (elevator) simulation test and a special equipment related management (elevator) certificate examination
Daily question - line 10
如何看待智慧城市建设中的改变和机遇?
TCP/IP 详解(第 2 版) 笔记 / 3 链路层 / 3.4 桥接器与交换机 / 3.4.2 多属性注册协议(Multiple Registration Protocol (MRP))
【硬十宝典】——1.【基础知识】电源的分类
【硬十宝典目录】——转载自“硬件十万个为什么”(持续更新中~~)
slf4j 简单实现
Internet winter, how to spend three months to make a comeback