当前位置:网站首页>51单片机一究到底输入模式
51单片机一究到底输入模式
2022-07-17 03:41:00 【small_planet】
实验条件:一个STC8G1K08开发板、一台电源箱、一个USB转TTL,就用这么多设备今天让我们对单片机的输入模式一探究竟。
上电的初始状态:

写的一个简单的程序来判断单片机识别的电压到底多少是0、多少是1,并对上拉、adc通道进行分别实验。
while(1)
{
//清看门狗
WDT_CONTR=0X36;
//printf("hello\r\n");
if(PORT==1)
{
printf("---1---\r\n\r\n");
}
else
{
printf("---0---\r\n\r\n");
}
for(i=0;i<5;i++)
{
WDT_CONTR=0X36;
delay_ms(200);
}
}高阻输入:
不确定态,电流不进去只采集电压。
悬空时为0,但如果把手放到引脚上就会判断为1,如果不加上拉或下拉效果是非常不好的。
判断1和0的分界点大概是在1.50v左右,这时会判断有时是1有时是0,不稳定。
如果是设置为ADC输入脚情况也一样。
高阻输入有上拉:为什么和不加是一样的效果??我配置的引脚应该没错啊,错的是什么??

找到了原因:PxPU寄存器是扩展 RAM 区特殊功能寄存器,对这些寄存器操作是需要把P_SW2的最高位置1才行!!! 不置1的话对P1PU的写没有用。
1.2v是分界线
准双向:
悬空的时候是1,其他的也和高阻输入是一样的效果。
需要注意的是,当接下拉电阻的时候要注意电阻的阻值,不可太大。我测试的时候接了一个1M的下拉电阻,结果我不论输入高电平还是低电平,都会判断为输入高电平,原因是单片机内部有一个弱上拉,电阻约为50k,我接的下拉电阻1M分走了大部分的电压,所以读的时候都为高电平。
边栏推荐
- sql界面切换不能获取焦点
- [database] must know and be able at the end of the term ----- Chapter 10 database programming
- IDEA及控制台 设置管理员权限
- 项目套价是什么意思?
- [database] must know and be able at the end of the term ----- Chapter 11 concurrency control
- Wechat Online Education video on Demand Learning of applet Graduation Design (3) Background Function
- String extension method usage
- 学术分享 | 基于OpenVINO的多染色病理图像信息评估系统设计与开发
- Common functions of JMeter - parametric introduction
- donet framework4.X==windows窗体应用新建项目,通过System.Data.SqlClient连接sqlserver进行查询
猜你喜欢

High performance and economy: aoteng persistent memory helps mobile cloud cope with severe memory challenges

Wechat online education video on demand learning applet graduation project (4) opening report

如何更有效的过滤病毒/垃圾邮件!

小程序毕设作品之微信电子书阅读小程序毕业设计(6)开题答辩PPT

How to do clear scanning: try scanning tailor scantailor advanced | including the usage of scantailor

Chapter 6 performance platform godeye source code analysis - Custom expansion module

图形验证码验证

Introduction au cadre Maui 05 compréhension du modèle de données mvvm

WPF cannot find resource file problem

Unity Shader - “快速“ 次散射 (Fast SSS : Fast Subsurface Scattering)
随机推荐
Deconstruction of typescript array / object / string / function parameters
IN Tech 2022|英特尔技术产品创新速览
String extension method usage
小程序毕设作品之微信电子书阅读小程序毕业设计(5)任务书
AttributeError: ‘NoneType‘ object has no attribute ‘sort‘
小程序毕设作品之微信电子书阅读小程序毕业设计(2)小程序功能
Dapr series (I)
Graphic verification code verification
小程序毕设作品之微信电子书阅读小程序毕业设计(1)开发概要
Idea configures SFTP and SSH, which is very convenient to deploy and locate error logs
巧用企业网盘收取报告或总结
英特尔+联想共同推出开源云解决方案
MAUI 框架入門學習05 MVVM數據模型理解
How to use mitmproxy to get data return in automated testing?
如何更有效的过滤病毒/垃圾邮件!
Introduction to Maui framework 05 MVVM data model understanding
Wechat official account page authorization 40029 error "suggested collection"
Use of anti shake debounce and throttling throttle
V4l2 learning materials collection
[database] must know and be able at the end of the term ----- Chapter 10 database programming