keil c51串口打印变量

#include <reg52.h>
#include <stdio.h>
#include <stdlib.h>

void main()
{
    unsigned char a = 256;
    int d = a;

    int c = (int)a;

    SCON = 0X50; 	//串口方式1,允许接收
    TMOD = 0X20; 	//定时器1定时方式2
    TCON = 0X40; 	//设定定时器1开始计数
    TH1 = 0XE8;		//11.0592MHz 1200波特率
    TL1 = 0XE8;
    TI = 1;
    TR1 = 1;
    while(1)
    {
        printf("c=%d\n", c);
        printf("d+1=%d\n", d + 1);
        printf("Hello world !\n");
    }


}

 F11 单步调试

 更加简洁的版本,设定中断标志位TI=1,发送完成:

#include <STC15Fxxxx.h>
#include <stdio.h>


void stic()
{
	unsigned char x=0;
	x++;
	printf("%bd \t",x);

}
void main()
{

	TI=1;
	printf("Hello world! \r\n");
	//stic();
	//stic();
	//stic();
	while(1);

}

 

posted @ 2019-04-15 14:42  微笑的''80  阅读(870)  评论(0)    收藏  举报