赞
踩
先给大家附上一套完整的模板源代码,此源代码适合的单片机型号是 STC89C52RC, 晶振是 11.0592MHz, 串口波特率是 9600, 初学者只需修改代码里从“C 语言学习区域的开始” 到“C 语言学习区域的结束” 的区域, 其它部分不要更改。 一套完整的模板源代码如下。
View函数如下:
- void View(unsigned long u32ViewData)
- {
- static unsigned char Su8ViewBuffer[43];
- code unsigned char Cu8_0D_0A[]={0x0d,0x0a,0x00};
- code unsigned char Cu8Start[]={"开始..."};
- static unsigned char Su8FirstFlag=0;
- static unsigned int Su16FirstDelay;
- if(0==Su8FirstFlag)
- {
- Su8FirstFlag=1;
- for(Su16FirstDelay=0;Su16FirstDelay<10000;Su16FirstDelay++);
- SendString(Cu8Start);
- SendString(Cu8_0D_0A);
- SendString(Cu8_0D_0A);
- }
- to_BufferData(u32ViewData,Su8ViewBuffer,1);
- SendString(Su8ViewBuffer);
- to_BufferData(u32ViewData,Su8ViewBuffer,2);
- SendString(Su8ViewBuffer);
- to_BufferData(u32ViewData,Su8ViewBuffer,3);
- SendString(Su8ViewBuffer);
- to_BufferData(u32ViewData,Su8ViewBuffer,4);
- SendString(Su8ViewBuffer);
- SendString(Cu8_0D_0A);
- }
SendString函数:
- void SendString(unsigned char *pu8String)
- {
- static unsigned int Su16SendCnt;
- static unsigned int Su16Delay;
- SCON=0x50;
- TMOD=0X21;
- TH1
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。