基于proteus的Hello MCU 实验
基本的串口配置及输出实验.
proteus 8.7以上打开,包括工程及源码.
单片机源程序如下:
- #include<reg52.h>
- #include<stdio.h>
- #include <string.h>
- void delay_us(unsigned int x)
- {
- while(x)
- {
- x=x-1;
- }
- }
- //串口通信初始化 现在不需要理解配置原理,能用就行
- void uart(void)
- {
- SCON=0x40; //串口通信工作方式1
- REN=1; //允许接收
- TMOD=0x20; //定时器1的工作方式2
- TH1=0xfd,TL1=0xfd;
- TI=1; //这里一定要注意
- TR1=1; //打开定时器
- }
- void main(void)
- {
- uart();
- while(1)
- {
- printf("Hellp MCU!\r\n");
- delay_us(65530);
- printf("Hellp World!\r\n");
- delay_us(65530);
- }
- }
复制代码
所有资料51hei提供下载:
proteus_HelloMCU.zip
(49.69 KB, 下载次数: 20)
|