当前位置:网站首页>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);
}
}边栏推荐
- Keepalived monitors the process and automatically restarts the service process
- China Mobile MCU product information
- Intel announced five new technological developments, including quantum computing, neural pseudo computing, machine programming, integrated optoelectronics, and secure computing
- 不同路径II[针对DFS的动态规划改进]
- Research on 3D model retrieval method based on two channel attention residual network - Zhou Jie - paper notes
- Accès à la boîte aux lettres du nom de domaine Lead à l'étranger
- Cglib dynamic proxy
- 韩信大招:一致性哈希
- LabVIEW jump to web page
- Vscode official configuration synchronization scheme
猜你喜欢

PI Ziheng embedded: This paper introduces the multi-channel link mode of i.mxrt timer pit and its application in coremark Test Engineering

VectorDraw Web Library 10.10
![对链表进行插入排序[dummy统一操作+断链核心--被动节点]](/img/2a/ccb1145d2b4f9fbd8d0812deace93b.png)
对链表进行插入排序[dummy统一操作+断链核心--被动节点]

高数基础_函数的奇偶性

The principle of Zener diode, what is its function?

This year, I graduated

Introduction to Sichuan Tuwei ca-is3082wx isolated rs-485/rs-422 transceiver
![[batch dos-cmd command - summary and summary] - add comment command (REM or::)](/img/e9/151885ecd490b0aa83cce0f3a49124.png)
[batch dos-cmd command - summary and summary] - add comment command (REM or::)

海思3559 sample解析:vio

Sichuan earth microelectronics high performance, high integration and low cost isolated 485 transceiver
随机推荐
ELK + filebeat日志解析、日志入库优化 、logstash过滤器配置属性
无“米”,也能煮“饭”利用“点云智绘”反演机载LiDAR林下缺失地面点攻略
Collection of common terms and meanings in forestry investigation based on lidar
Three years of continuous decline in revenue, Tiandi No. 1 is trapped in vinegar drinks
关于硬件问题造成的MCU死机,过来人简单的谈一谈
Redis learning notes
【批处理DOS-CMD命令-汇总和小结】-cmd扩展命令、扩展功能(cmd /e:on、cmd /e:off)
鸿蒙页面菜单的选择
Accès à la boîte aux lettres du nom de domaine Lead à l'étranger
Application of point cloud intelligent drawing in intelligent construction site
Tupu software digital twin 3D wind farm, offshore wind power of smart wind power
几款不错的天气插件
一“石”二“鸟”,PCA有效改善机载LiDAR林下地面点部分缺失的困局
Chuantu microelectronics 𞓜 subminiature package isolated half duplex 485 transceiver
太上老君的炼丹炉之分布式 Quorum NWR
NSIS 静默安装vs2013运行时
Tempest HDMI leak receive 2
【批處理DOS-CMD命令-匯總和小結】-cmd擴展命令、擴展功能(cmd /e:on、cmd /e:off)
[batch dos-cmd command - summary and summary] - application startup and call, service and process operation commands (start, call, and)
Notes: [open class] neural network and deep learning -- tensorflow2.0 actual combat [Chinese course]