当前位置:网站首页>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);
}
}边栏推荐
- [Batch dos - cmd Command - Summary and Summary] - External Command - cmd Download Command, wget Command
- Without "rice", you can cook "rice". Strategy for retrieving missing ground points under airborne lidar forest using "point cloud intelligent mapping"
- Full range of isolator chips with integrated isolated power supply
- Application of point cloud intelligent drawing in intelligent construction site
- [batch dos-cmd command - summary and summary] - commands related to Internet access and network communication (Ping, Telnet, NSLOOKUP, ARP, tracert, ipconfig)
- MySQL face Scripture eight part essay
- College entrance examination voluntary filling, why is the major the last consideration?
- FairMOT yolov5s转onnx
- How comfortable it is to use Taijiquan to talk about distributed theory!
- The perfect presentation of Dao in the metauniverse, and platofarm creates a farm themed metauniverse
猜你喜欢

Research on 3D model retrieval method based on two channel attention residual network - Zhou Jie - paper notes

My debut is finished!

CPDA | how to start the growth path of data analysts?

VectorDraw Web Library 10.10

正版photoshop2022購買體驗經曆分享

用动图讲解分布式 Raft

Shell tips (134) simple keyboard input recorder

Cocos learning diary 3 - API acquisition nodes and components

13 `bs_duixiang.tag标签`得到一个tag对象

PI Ziheng embedded: This paper introduces the multi-channel link mode of i.mxrt timer pit and its application in coremark Test Engineering
随机推荐
Tempest HDMI leak receive 1
Chuantu microelectronics ca-if1051 can-fd transceiver
[batch dos-cmd command - summary and summary] - CMD window setting and operation commands (CD, title, mode, color, pause, CHCP, exit)
数据可视化没有重点怎么办?
诸葛亮 VS 庞统,拿下分布式 Paxos
Different paths ii[dynamic planning improvement for DFS]
【批处理DOS-CMD命令-汇总和小结】-文件与目录操作命令(md、rd、xcopy、dir、cd、set、move、copy、del、type、sort)
VectorDraw Developer Framework 10.10
College entrance examination voluntary filling, why is the major the last consideration?
Explain distributed raft with dynamic diagram
【批處理DOS-CMD命令-匯總和小結】-外部命令-cmd下載命令、抓包命令(wget)
shell小技巧(一百三十四)简单的键盘输入记录器
Global variables & local variables
Sichuan earth microelectronics high performance, high integration and low cost isolated 485 transceiver
LTpowerCAD II和LTpowerPlanner III
smartBugs安装小问题总结
MySQL facet 01
Common functions of OrCAD schematic
[batch dos-cmd command - summary and summary] - file and directory operation commands (MD, RD, xcopy, dir, CD, set, move, copy, del, type, sort)
What is the difference between norflash and nandflash