51 single-chip computer printf use method

Source: Internet
Author: User

Today in the group there is a Netizen mentioned 51 single-chip computer using printf why the compilation passed, but no effect. Here to share my notes, the experiment itself does not make much sense, mainly to record 51 how the single-chip microcomputer should use the printf function.


Experiment Name: Serial communication single chip microcomputer and PC calculation trapezoid area

MCU model: STC12C5A60S2 (12T mode)

Crystal oscillator : 11.0592MHZ

Experimental content: The use of single-chip microcomputer and PC serial communication work Mode 1 (baud rate variable), (has crystal oscillator 11.0592MHZ) set baud rate of 9600b/s, combined with timer 1 mode of Operation 2 (TH1=0XFD,TL1=0XFD), input ladder of the upper end, bottom, high, Output trapezoid Area


Reference program:

/* File name: Serial communication value single chip microcomputer and PC compute trapezoid area. C Creator: Yangrui created: February 20, 2013 development environment: HOT51 Enhanced Microcontroller Development Board program function: the use of single-chip microcomputer and PC serial communication, calculate trapezoid area attached: The use of single-chip microcomputer and PC serial communication work Mode 1 (baud rate variable) , (known crystal oscillator 11.0592MHZ) set the communication baud rate of 9600b/s, combined with the Timer 1 mode of Operation 2 (TH1=0XFD,TL1=0XFD), input the bottom, bottom, high, output trapezoid area hint: After downloading the program, open the serial tool, need to reset a bit. */#include <reg52.h> #include <stdio.h> #define UINT unsigned int #define UCHAR unsigned charvoid uart (void)// Serial communication Initialization {scon=0x40;//serial communication operation mode 1ren=1;//allow to receive tmod=0x20;//Timer 1 mode of operation 2th1=0xfd,tl1=0xfd; Ti=1;                       It is important to note that tr1=1;//opens the timer}void main (void) {uint up=0,down=0,high=0;uint result; UART (); while (1) {printf ("************** \ r \ n ");p rintf (" 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);}}



51 single-chip computer printf use method

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.