proteus单片机的波特率怎么设置,proteus怎么对单片机编程

首页 > 经验 > 作者:YD1662022-10-30 07:08:15

//main.c #include <reg52.h> #include "delay.h" #include "uart.h" void main() { unsigned char dat = 88; unsigned int dat2 = 1250; float dat3 = 12.5; UartInit(); while(1) { printf("Hello World\r\n"); printf("dat = %bu\r\n",dat); printf("dat2 = %u\r\n",dat2); printf("dat3 = %f\r\n",dat3); delayXms(2000); } }

//uart.c #include <reg52.h> #include "uart.h" void UartInit(void)//4800bps@11.0592MHz { SCON = 0x50; //8位数据,可变波特率SM0 SM1 SM2 REN TB8 RB8 TI TI TMOD &= 0x0F; //清除定时器1模式 TMOD |= 0x20; //设定定时器1为8位自动重装方式 TL1 = 0xFA; //设定定时初值 TH1 = 0xFA; //设定定时器重装值 ET1 = 0; //禁止定时器1中断 TR1 = 1; //启动定时器1 } void sendByte(unsigned char dat) { SBUF = dat; while(!TI); TI = 0; } void sendString(unsigned char *dat) //Hello World! { while(*dat != '\0') { sendByte(*dat ); } } char putchar(char c) { sendByte(c); return c ; }

//uart.h #ifndef _UART_H_ #define _UART_H_ #include <reg52.h> #include <stdio.h> void UartInit(void); void sendByte(unsigned char dat); void sendString(unsigned char *dat); char putchar(char c); #endif

proteus单片机的波特率怎么设置,proteus怎么对单片机编程(1)

proteus单片机的波特率怎么设置,proteus怎么对单片机编程(2)

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.