当前位置:网站首页>Simple verification code generator for 51 single chip microcomputer experiment
Simple verification code generator for 51 single chip microcomputer experiment
2022-07-02 14:36:00 【Xiao Xiao's pig can fly】
well !! Long time no see , With all of you
Will you miss the pig ?
Um. … Why not ?
ヾ(≧ ▽ ≦)ゝ
List of articles
Preface :
This paper is an experiment done by autonomous learning , There may be many deficiencies , Please point out !!
One , Abstract
This comprehensive experimental report is written according to the topic given by the experimental subject , The subject content is the verification code generator . Mainly through the use of the single-chip microcomputer serial communication learned this semester 、 Liquid crystal display LCD1602、 Serial port interrupt system 、 The related content of external interrupt realizes a slave host ( Input in the virtual terminal ) Send to the slave 6 Verification information of digit number or letter verification code , After receiving through the sub machine, it will be in LCD1602 It shows that . In order to verify whether it is received accurately , Here we also design a LCD1602 The LCD displays the content sent on the virtual terminal , To check whether the sub machine receives correctly . This experiment simply simulates the sending mechanism of verification code in digital communication , The following is the whole content of the experiment .
Two , Purpose
Through this experiment to improve this stage of single-chip learning , By the way, make a summary , Mainly the content of serial communication , Prepare to touch the embedded , That is to prepare for the following study .
3、 ... and , Functional specifications
Enter a 6 A letter or number of digits or a combination of numbers and letters , The host LCD1602 The input data is displayed on the LCD screen , Press the key to send the data to the slave , In the sub machine LCD1602 The data is displayed on the display . From the perspective of verification code generator, it is that the host sends verification code to the slave , The verification code received by the sub machine can match the host , Check whether the verification code is consistent .
Function description of each part :
(1) host AT89C51 And sub machine AT89C51:4k byte Flash Flash memory ,128 Inside the byte RAM,32 individual I/O Mouth line , Two 16 Bit timing / Counter , One 5 Vector two-level interrupt structure , A full duplex serial communication port , On chip oscillator and clock circuit . meanwhile ,AT89C51 Can be reduced to 0Hz Static logic operation of , It also supports two optional power-saving working modes of software . Idle mode stops CPU The job of , But allow RAM, timing / Counter , The serial communication port and interrupt system continue to work . Save by power failure RAM The content in , However, the oscillator stops working and all other components are prohibited from working until the next hardware reset .
(2)LCD1602 Liquid crystal display : The liquid crystal in the form of dot matrix is composed of M×N It consists of two display units , hypothesis LCD The display has 64 That's ok , Each row has 128 Column , Every time 8 Columns correspond to 1 Bytes of 8 position , That is, each line consists of 16 byte , common 16×8=128 A point of . On the screen 64×16 A display unit and a display unit RAM District 1024 Bytes correspond to , The content of each byte corresponds to the light and dark of the corresponding position on the display screen . For example, the brightness of the first line of the display screen is determined by RAM District 000H~00FH Of 16 The contents of bytes determine , When (000H)=FFH when , A short bright line appears in the upper left corner of the screen , The length is 8 A little bit ; When (3FFH)=FFH when , A short bright line appears in the lower right corner of the screen ; When (000H)=FFH,(001H)=00H,(002H)=00H…,(00EH)=00H,(00FH)=00H when , At the top of the screen, a message from 8 A bright line and 8 A dotted line composed of dark lines . This is it. LCD Basic principle of display .lcd1602 Mainly used to display numbers , Letter , Graphics and some custom characters . Because of its simple display control and high cost performance , It is widely used in electronic instruments , The refrigerator , Air conditioner , Automotive electronic instruments and other equipment .
(3) Virtual terminal : share 4 Terminals , among RXD It is the data receiving end ,TXD It is the data sender ,RTS Send a signal for the request ,CTS To clear the transfer , It's right RTS The response signal .Proteus The virtual terminal provided is equivalent to the dual functions of keyboard and screen , It eliminates the simulation model of the upper computer system , When users use the serial communication between MCU and host computer , Directly from the virtual terminal through RS-232 The model sends and receives data asynchronously with the MCU . Here, only the function of sending data by virtual terminal is used .
Four , Hardware circuit design
Name of components used :AT89C51、BUTTON、LM016L、POT
In this experiment, we use AT89C51 Of I/O Interface P2 Connect LCD1602 Monitor , Thus, the received data is displayed in LCD1602 On the screen . The host AT89C51 Upper RXD Connect... On the virtual terminal TXD, So as to receive the data input by the virtual terminal , On a host computer TXD Connect the RXD Send data to the slave . Key connection P3^2 mouth , Use external interrupts 0 control .
5、 ... and , Programming
(1) The first thing to talk about here is LCD1602 file , We all know that learning SCM , In learning this part , The teacher will give the corresponding LCD1602 The header file , The header file is relatively perfect . But here , We need to write the corresponding content by ourselves , Because what I need to achieve here is input by the virtual terminal, so I'm writing .c When programming, you should put the content of the defined function into the host and sub machine , You can't directly use what is given on the Internet or by teachers LCD1602 The header file , It needs to be changed .
First, let's look at the original header file :
open intrins.h You can see the commands in the header file , We can quote the header and tail to indicate that there is this header file , You can define the commands you need , In this way, you will clearly know the function commands and variables you need to use . Here's the picture
After defining the required variables, you can write LCD1602 Of .c The file , as follows :
(2) The host .c file
from main Function start :
from main The function shows , Here are several functions :
1, Window function
effect : Define the working mode of serial port 1 And regular working mode 1, Set the baud rate to 9600( You can design it yourself ), Turn on the total interrupt and serial port interrupt .
2, External interrupt switch function
effect : Open external interrupt ( Key control data transmission )
3,LCD1602 Initialization function
4, Sending function
effect : When the key is pressed, the data is sent to the slave
5, Show function
( Attention should be paid to the above analysis , There is no repeated parsing here , You can ask me if you don't understand )
effect : Display data on the display .
(3) Host all .c file
This is the simple function of the host of the verification code sending mechanism
(4) Subprogram
The subroutine is simpler than the host , But they are all similar , Don't do too much parsing .
6、 ... and , Simulation
Here's a reminder : The baud rate of the virtual terminal needs to be designed according to the baud rate set by itself .
All right. ! Treasure children , That's all about the experiment , I hope it can help you to 51 SCM has a further understanding
If this article is helpful to you or you like small bloggers , Remember to like comments and pay attention ! Or you won't find me o(▽)q
Support small bloggers a lot
Let's cheer together
边栏推荐
- Stm32-dac Experiment & high frequency DAC output test
- There is no solution to the decryption error of the remote user 'sa' and the service master password mapped from the remote server 'to the local user' (null) /sa '
- Fabric. JS zoom canvas
- Fabric.js 缩放画布
- taobao.trades.sold.get-查询卖家已卖出的交易数据(根据创建时间),淘宝店铺卖出订单查询API接口,淘宝R2接口,淘宝oAuth2.0交易接口代码分享
- Custom events, global event bus, message subscription and publishing, $nexttick
- taobao.trade.get( 获取单笔交易的部分信息),淘宝店铺订单接口,淘宝oAuth2.0接口,淘宝R2接口代码对接分享
- Certik released the defi security report in 2021, disclosing key data of industry development (PDF download link attached)
- 《可供方案开发》口算训练机/数学宝/儿童口算宝/智能数学宝 LCD液晶显示驱动IC-VK1622(LQFP64封装),原厂技术支持
- Fabric.js 手动加粗文本iText
猜你喜欢
Essential elements of science fiction 3D scenes - City
Yolov3 & yolov5 output result description
[development environment] 010 editor tool (tool download | binary file analysis template template installation | shortcut key viewing and setting)
obsidian安装第三方插件——无法加载插件
[development environment] StarUML tool (download software | StarUML installation | StarUML creation project)
The most complete analysis of Flink frame window function
A white hole formed by antineutrons produced by particle accelerators
Design and implementation of car query system based on php+mysql
天猫商品详情接口(APP,H5端)
ONNX+TensorRT:将预处理操作写入ONNX并完成TRT部署
随机推荐
抓包工具fiddler学习
freemarker的使用
[development environment] StarUML tool (download software | StarUML installation | StarUML creation project)
Using computed in uni app solves the abnormal display of data () value in tab switching
[apipost] tutorial
Thymeleaf dependency
STM32标准固件库函数名记忆(二)
Quarkus学习四 - 项目开发到部署
ONNX+TensorRT:将预处理操作写入ONNX并完成TRT部署
Adhere to the foundation of 20 minutes go every day II
Some interview suggestions for Android programmers "suggestions collection"
Chinese science and technology from the Winter Olympics (III): the awakening and evolution of digital people
Fatal: unsafe repository is owned by someone else
docker mysql
1、编辑利器vim
Design and implementation of car query system based on php+mysql
Threejs controller cube space basic controller + inertia control + flight control
go操作redis
Actual combat sharing of shutter screen acquisition
1. Editing weapon VIM