当前位置:网站首页>Blue Bridge Cup single chip microcomputer (I) -- turn off peripherals and turn off led
Blue Bridge Cup single chip microcomputer (I) -- turn off peripherals and turn off led
2022-06-23 11:50:00 【There is heavy snow in the South】
Recently, I began to prepare for the Blue Bridge Cup SCM competition in September , I bought a development board and began to learn . I have studied before 51 Single chip microcomputer , Compared with CT107D MCU competition board V20,51 The operation of single chip microcomputer is indeed much simpler , But the principle is the same , Nothing has changed , Previous studies 51 I didn't take notes when I was , Now I want to look for my previous study notes , So now after learning, I will post my notes on my blog , By the way, add some of your own learning experience , It's convenient for you to find it later , If there is a mistake , Welcome to correct .
When you create a project , The chip I chose was STC15F2K60S2, Of course, you can choose AT89C51 or AT89C52, When our development board is powered on , Buzzer and LED It's all on by default , The buzzer sounds uncomfortable and noisy after listening to it for a long time , And the game often requires that the peripherals be turned off first , That is, turn off the buzzer and LED. Because of MCU IAP15F2K61S2 There are not many interfaces , And the single-chip operation also needs to use many functions , So here in the circuit we use 74HC573 The effect of latch on SCM P0 Mouth for buffering , When we need to use the corresponding functions , Open the corresponding latch , Input and output .
When enabling end Y4C For high voltage ,Q Output with D Input and change , Enable end Y4C Low power level , The output will be locked at the established data level .
Enable end Y4C The level of , Is through an input or not gate and 74HC138 Jointly controlled by the decoder . Here's the picture :
74HC02 Is an input or not gate , The principle is :
Y4C The output is zero Y4,WR Take the value after first or then reverse ,WR The connection is GND, Is a low level ,Y4C To get a high level , Activate 74HC53 Latch ,Y4 It must be low level ,Y4 Again through 74HC138 The decoder implements , as follows :
138 The decoder passes P27~P25 The level of the three input ports is controlled Y0 ~Y7 Output , When Y0 ~Y7 Either output is low , Is valid output .
such as ,Y4 Namely P27~ P25 by 100 Valid output of , Binary algorithm ,100 by 4, Again , If you want to make Y5 It works ,P27~ P25 The input of should be 101, By analogy . Please read the chip principle by yourself 74HC138 Chip data .
therefore , The circuit controls 138 Of the decoder P27~P25 To control the switch of each latch .
In the circuit schematic diagram , The buzzer is activated by Y5C This port is controlled by a latch , therefore , To operate the buzzer , The latch must be opened first Y5C,
P2 = P2 & 0x1f | 0xa0; // First the P27~P25 Zero clearing , Then open the latch Y5C,
In the connecting circuit ,74HC573 The output of the Q I got one ULN2003,ULN2003 The function here is to negate , It is when we input high level , After this, the output is low level .
The buzzer is connected VCC, That's high level 1, All that needs to be transferred here is the low level 0, The buzzer will work , Will ring . We need to turn off the buzzer first , because ULN2003 The reaction of , When we don't need these peripherals , Just put this P0 Set the mouth to zero .
P2 = P2 & 0x1f | 0xa0; P0 = 0x00; // 1010 0000 Open the latch Y5C, Turn off the buzzer
Of course , When you need to turn on the buzzer , Reset the corresponding pin port 1 that will do . such as , Now you need to turn on the buzzer :
P2 = P2 & 0x1f | 0xa0; P0 = 0x40; // 1010 0000 Open the latch Y5C, Turn off the buzzer
As shown in the schematic diagram above ,P07~P00 It is controlled by hexadecimal code ,0000 0000, To turn on the buzzer , Is to P06 Set to high level , namely :0100 0000, therefore ,P0 The port is 0x40.
below , After turning off the buzzer , We need to shut down LED The lamp , close LED The principle of the lamp is the same as that of turning off the buzzer , Just open the corresponding latch , Carry out corresponding operations .
adopt 138 The decoder and 74HC02 Enable end Y4C High level 1,LED Followed by VCC, So from P0 Port input low level 0,LED Light on , If high 1,LED The light goes out .
P2 = P2 & 0x1f | 0x80; P0 = 0xff; // 1000 0000 Open the latch Y4C, close LED
control LED Eight pin ports of P07~P00, When all are extinguished :1111 1111 When you need to light a LED, Just set the corresponding pin port to zero ( Set to low level ) that will do . For example, it should be bright LED1, Namely :1111 1110 namely P0=0xfe.
my LED It will light up slightly at the beginning of closing , This phenomenon does not appear after other functions are added .
There may be many places in the text where the words are not particularly professional , There is a mistake .
边栏推荐
- 得物多活架构设计之路由服务设计
- The computer broke down. I changed the computer. There was a problem installing the node environment. The URL is not defined
- 语音数据标注工具与平台
- 在工作中学习的三个方法
- 股票网上开户及开户流程怎样?手机开户安全么?
- Leetcode 1209. Delete all adjacent duplicates II in the string (not in the initial version)
- 请问,maxcompute执行sql查询有时特别慢是什么原因
- 2光2电级联型光纤收发器千兆2光2电光纤收发器迷你嵌入式工业矿用本安型光纤收发器
- How Huawei cloud implements a global low latency network architecture for real-time audio and video
- OpenHarmony应用开发【01】
猜你喜欢

Analysis of LinkedList source code

OpenHarmony应用开发【01】
![Openharmony application development [01]](/img/b1/1e37cecd3d3f9e46444c202cfb1b99.png)
Openharmony application development [01]

@黑马粉丝,这份「高温补贴」你还没领?

【ML】QuantileRegressor

tensorflow2的GradientTape求梯度

【云原生&微服务八】Ribbon负载均衡策略之WeightedResponseTimeRule源码剖析(响应时间加权)

电脑坏了,换了台电脑,装node环境的时候出了问题,报错URL not defined

Vone news | wanglian technology empowers the public to enjoy the self-organization management of the chain network, creating an enterprise level alliance Dao

Getting started with redis - Chapter 4 - data structures and objects - jump table
随机推荐
电脑坏了,换了台电脑,装node环境的时候出了问题,报错URL not defined
Video data annotation tools and platforms (data annotation company)
At 14:00 today, 12 Chinese scholars started ICLR 2022
【云驻共创】无码时代,软件开发如何走向每个人?
WC statistics are out of date, and every line of cloc code is valid
2022年全国最新消防设施操作员(初级消防设施操作员)模拟题及答案
开源之夏中选名单已公示,基础软件领域成为今年的热门申请
32路电话+2路千兆以太网32路PCM电话光端机支持FXO口FXS语音电话转光纤
CIFAR公开第二阶段泛加拿大AI战略
【综合笔试题】30. 串联所有单词的子串
Meta said that the UK security law may "scan all private information" or infringe privacy
杜邦分析法解读:安阳钢铁股份有限公司企业投资价值何在?
Getting started with redis - Chapter 4 - data structures and objects - jump table
Three ways to learn at work
Go 语言使用 MySQL 的常见故障分析和应对方法
Gradienttape of tensorflow2
Simulation questions and answers of the latest national fire-fighting facility operators (primary fire-fighting facility operators) in 2022
Google Earth Engine(GEE)——GEDI L2A Vector Canopy Top Height (Ver
The country has entered the main flood season. The Ministry of transport: the lines that do not meet the conditions for safe operation will be resolutely shut down!
On the structure of annotation platform