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