当前位置:网站首页>[STM32 learning] (14) two 74HC595 controls four nixie tube displays
[STM32 learning] (14) two 74HC595 controls four nixie tube displays
2022-07-24 09:51:00 【Use small materials】
74HC595 It is one of the commonly used chips in single chip microcomputer system. Its function is to convert serial signals into parallel signals , Commonly used in all kinds of digital tubes and dot matrix screen driver chips , Use 74HC595 Can save MCU mcu Of io Oral resources , use 3 individual io You can control 8 A pin of a nixie tube , He also has certain driving ability , It can eliminate the amplification circuit such as triode , So this chip is an artifact that drives digital tubes . Very widely used .

74HC595 Pin figure

74HC595 Pin function

The model of single chip microcomputer I choose is :STM32L052K8 Series of low power chips , In fact, with F4 Series and F1 Series are the same .
Let's take a look at the wiring :

You can clearly see the connection with the MCU from the above figure .
Two 595 Connect through cascading .
The two nixie tubes have a common anode
How to implement the code ?

So we can write 595 Driver program , as follows :
/**********************************/
/** The name of the function :void HC595_Write_Data(unsigned char dis_data) **/
/** Input parameters :unsigned char dis_data Data to be entered */
/** The functionality : Write the data into 74HC595 in */
/** ****************************** **/
void HC595_Write_Data(unsigned char dis_data)
{
unsigned char i;
unsigned char temp;
temp = dis_data;
for(i=0;i<8;i++) // Loop writes the eight bits of a byte to the register in turn
{
HAL_GPIO_WritePin(SRCLK_GPIO_Port,SRCLK_Pin,GPIO_PIN_RESET);// SRCLK Low level
if(temp & 0X80)
{
HAL_GPIO_WritePin(DATA_GPIO_Port,DATA_Pin,GPIO_PIN_SET);
}
else
{
HAL_GPIO_WritePin(DATA_GPIO_Port,DATA_Pin,GPIO_PIN_RESET);
}
temp = temp<<1;
HAL_GPIO_WritePin(SRCLK_GPIO_Port,SRCLK_Pin,GPIO_PIN_RESET); // SRCLK Low level
HAL_GPIO_WritePin(SRCLK_GPIO_Port,SRCLK_Pin,GPIO_PIN_SET); // SRCLK High level
}
}
/****************************************/
/** The name of the function :void Disp_out(void)*/
/** Function parameter : No arguments */
/** The functionality : Output the data written to the register to the port display */
/****************************************/
void Disp_out(void)
{
HAL_GPIO_WritePin(RCLK_GPIO_Port,RCLK_Pin,GPIO_PIN_RESET);
HAL_GPIO_WritePin(RCLK_GPIO_Port,RCLK_Pin,GPIO_PIN_SET);
}IO The initialization function of the port is : Are set to push the output , Just don't pull up
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, SRCLK_Pin|DATA_Pin, GPIO_PIN_SET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(RCLK_GPIO_Port, RCLK_Pin, GPIO_PIN_SET);
/*Configure GPIO pins : SRCLK_Pin DATA_Pin */
GPIO_InitStruct.Pin = SRCLK_Pin|DATA_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pin : RCLK_Pin */
GPIO_InitStruct.Pin = RCLK_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(RCLK_GPIO_Port, &GPIO_InitStruct);
}Now we want to dynamically display 1234
The main function code is :
int main(void)
{
MX_GPIO_Init();
while (1)
{
HC595_Write_Data(0x01); // Select the first digital tube
HC595_Write_Data(0x99);
Disp_out();
HAL_Delay(2); // Time delay 2ms
HC595_Write_Data(0x02); // Select the second digital tube
HC595_Write_Data(0xb0);
Disp_out();
HAL_Delay(2); // Time delay 2ms
HC595_Write_Data(0x04); // Select the third digital tube
HC595_Write_Data(0xa4);
Disp_out();
HAL_Delay(2); // Time delay 2ms
HC595_Write_Data(0x08); // The fourth nixie tube
HC595_Write_Data(0xf9); //
Disp_out();
HAL_Delay(2); // Time delay 2ms
}
}The effect is as shown in the picture :

There is a little hint : When there is 595 When cascading , If there are two fast 595 cascade .
HC595_Write_Data(0x01); // Select the first digital tube The first data will be cascaded to the second block 595 In chip
HC595_Write_Data(0x99); // The data sent later is the first piece 595 Data from the chip
Disp_out(); // Finally, the data is transmitted to their respective ports , Carry out functional operation It's over here , You can learn from each other , offer a proposal .
边栏推荐
- [don't bother with reinforcement learning] video notes (I) 1. What is reinforcement learning?
- C # +opencvsharp+wpf learning notes (I)
- Wenxin big model raises a new "sail", and the tide of industrial application has arrived
- Arduino drive Lora module node
- [don't bother to strengthen learning] video notes (III) 2. SARS learning realizes maze walking
- When the hot tea is out of stock, what does the new tea drink rely on to continue its life?
- 云原生(十二) | Kubernetes篇之Kubernetes基础入门
- Tencent 5g innovation center was established, laying out key directions such as unmanned ports, smart mines and E-sports events
- Centos7 install mysql8.0
- At the moment of the epidemic, we need to work harder, aoligui
猜你喜欢

Opencv learning Day5
![[don't bother with reinforcement learning] video notes (I) 1. What is reinforcement learning?](/img/84/48a6a83192a12dafd88bcd74db0955.gif)
[don't bother with reinforcement learning] video notes (I) 1. What is reinforcement learning?

Raspberry Pie:: no space left on device

MySQL基础篇(一)-- SQL基础
![[note] what is kernel / user space? Let's start with how the CPU runs the program](/img/b5/0ab4f2841faf3573b4502d2cd09069.png)
[note] what is kernel / user space? Let's start with how the CPU runs the program

力扣300-最长递增子序列——动态规划

2022 trusted cloud authoritative assessment released: Tianyi cloud has obtained ten certifications and five best practices

Compilation and linking of programs

Implementation principle of acid in MySQL

Where is the bitbucket clone address
随机推荐
Compilation and linking of programs
MySQL query database capacity size
配置系统环境变量的时候误删了Path怎么办?
Getting started with identityserver4
This article takes you to understand the dynamic memory allocation of C language
Simple parsing JSON strings with regular expressions
PHP Basics - session control - cookies
Spark Learning: implement compact table command
Dorissql syntax Usage Summary
Gin framework uses session and redis to realize distributed session & Gorm operation mysql
PHP debugging tool - how to install and use firephp
How to improve office efficiency through online collaborative documents
Centos7 install mysql8.0
Wenxin big model raises a new "sail", and the tide of industrial application has arrived
At the moment of the epidemic, we need to work harder, aoligui
PHP caching system - PHP uses Memcache
Countdownlatch and join [concurrent programming]
OPENCV学习DAY5
Installation UMI tutorial (error reporting and solutions)
Hands on deep learning (VII) -- bounding box and anchor box