当前位置:网站首页>How to use printf of 51 single chip microcomputer
How to use printf of 51 single chip microcomputer
2022-06-25 07:42:00 【Assassin ari】
Today, a netizen in the group mentioned 51 Use of single chip microcomputer printf Why did the compiler pass , But it didn't work . Here are my notes to share , The experiment itself doesn't make much sense , Mainly records 51 How should SCM be used Printf function .
Name of the experiment : Single chip microcomputer and serial port communication PC Calculate the trapezoidal area
MCU model :STC12C5A60S2(12T Pattern )
Crystal oscillator :11.0592MHZ
Experimental content : Using single chip microcomputer and PC The working mode of serial port communication 1( The baud rate is variable ),( Crystal vibration has been 11.0592MHZ) Set the baud rate to 9600B/S, Combined timer 1 How it works 2(TH1=0xfd,TL1=0xfd), Input the top and bottom of trapezoid 、 Bottom 、 high , Output trapezoidal area
design sketch :
Reference procedure :
/*
file name : Serial port communication value SCM and PC The computer calculates the trapezoidal area .c
founder : Yang Rui
Creation time :2013 year 2 month 20 Japan
development environment :HOT51 Enhanced MCU development board
Program function : Using single chip microcomputer and PC Serial port communication of computer , Calculate the trapezoidal area
attach : Using single chip microcomputer and PC The working mode of serial communication of the computer 1( The baud rate is variable ),( The crystal oscillator is known to be 11.0592MHZ) Set the communication baud rate to 9600b/s, Combined timer 1 How it works 2(TH1=0xfd,TL1=0xfd), Enter the bottom 、 Bottom 、 high , Output trapezoidal area
Tips : After downloading the program , Open the serial port tool , It needs to be reset .
*/
#include<reg52.h>
#include<stdio.h>
#define uint unsigned int
#define uchar unsigned char
void uart(void) // Serial communication initialization
{
SCON=0x40; // Working mode of serial communication 1
REN=1; // Allow to receive
TMOD=0x20; // Timer 1 How it works 2
TH1=0xfd,TL1=0xfd;
TI=1; // It's important to be careful here
TR1=1; // Turn on timer
}
void main(void)
{
uint up=0,down=0,high=0;
uint result ;
uart();
while(1)
{
printf("********************************\r\n");
printf("Please input up,dowm,high:\r\n");
scanf("%d%d%d",&up,&down,&high) ;
printf("\r\nResult=%d\r\n",result=(up+down)*high/2);
}
}
边栏推荐
- Research on 3D model retrieval method based on two channel attention residual network - Zhou Jie - paper notes
- Zhugeliang vs pangtong, taking distributed Paxos
- Estimation of dense forest volume based on LIDAR point cloud with few ground points
- 无“米”,也能煮“饭”利用“点云智绘”反演机载LiDAR林下缺失地面点攻略
- Harmony美食菜单界面
- 13 `bs_duixiang.tag标签`得到一个tag对象
- Pit encountered by pytorch: why can't l1loss decrease during model training?
- Cglib dynamic proxy
- Audio (V) audio feature extraction
- What if there is no point in data visualization?
猜你喜欢
Cocos learning diary 3 - API acquisition nodes and components
Ns32f103c8t6 can perfectly replace stm32f103c8t6
【批处理DOS-CMD命令-汇总和小结】-外部命令-cmd下载命令、抓包命令(wget)
Sichuan Tuwei ca-is3105w fully integrated DC-DC converter
高数基础_函数的奇偶性
Weimeisi new energy rushes to the scientific innovation board: the annual revenue is 1.7 billion, and the book value of accounts receivable is nearly 400million
[distillation] pointdistiller: structured knowledge distillationwards efficient and compact 3D detection
Notes: [open class] neural network and deep learning -- tensorflow2.0 actual combat [Chinese course]
Mysql database import SQL file display garbled code
鸿蒙页面菜单的选择
随机推荐
【Qt】快捷键
What if there is no point in data visualization?
诸葛亮 VS 庞统,拿下分布式 Paxos
音频(五)音频特征提取
RTKLIB-b33版本中GALILEO广播星历存储问题
函数模板_类模板
Vscode official configuration synchronization scheme
几款不错的天气插件
Chuantuwei ca-is3720lw alternative material No. iso7820fdw
Common functions of OrCAD schematic
useMemo模拟useCallback
Can I open a stock account with a compass? Is it safe?
LabVIEW jump to web page
[QT] shortcut key
Unity3D邪门实现之GUI下拉菜单Dropdown设计无重复项
NSIS 静默安装vs2013运行时
(tool class) quickly add time to code in source insight
[pytest] modify the logo and parameterization in the allure Report
【批处理DOS-CMD命令-汇总和小结】-文件与目录操作命令(md、rd、xcopy、dir、cd、set、move、copy、del、type、sort)
realsense d455 semantic_slam实现语义八叉树建图