如果您无法下载资料,请参考说明:
1、部分资料下载需要金币,请确保您的账户上有足够的金币
2、已购买过的文档,再次下载不重复扣费
3、资料包下载后请先用软件解压,在使用对应软件打开
STC12C5A系列单片机串口编程串口头文件uart.h如下:===================================================================/**File:uart.h*Description:ThisfileisUARTdriverheaderofSTC12C5Aserialsignalchip.*Author:Chao*Copyright:Chao**History*----------------------*Rev:0.0*Date:20/08/2011**create.*----------------------*/#ifndefUART_H_#defineUART_H_//---------------Config-------------------------//#defineUART1_EN//使能串口1#defineUART1_RECEIVE_EN//允许串口1中断接收函数#defineUART2_EN//使能串口2#defineUART2_RECEIVE_EN//允许串口2中断接收函数//#defineECHO//使能回显//---------------Defines-------------------------//#defineSystemFosc22118400//系统时钟:22.1184MHz#defineUartBaud9600//串口波特率#defineUART_BUFFER_SIZE16//串口数据缓冲区大小#defineUartEndChar'>'//串口数据结束字符//---------------Typedefine-------------------------//typedefstruct{unsignedintreceive_flag;//数据接收标志unsignedchardata_length;//数据缓冲区中有效数据个数unsignedcharreceive_buffer[UART_BUFFER_SIZE];//数据接收缓冲区void(*init)(void);//串口初始化函数void(*send_byte)(unsignedcharddata);//发送单个字符void(*send_string)(unsignedchar*ddata,unsignedcharlength);//发送字符串}UART_T;//---------------Extern-------------------------//#ifdefUART1_ENexternUART_Tuart1;#endif#ifdefUART2_ENexternUART_Tuart2;#endif#endif/*UART_H_*/========================================================================串口编程C程序文件uart.c如下:========================================================================/**File:uart.c*Description:ThisfileisUARTdriverofSTC12C5Aserialsignalchip.*Author:Chao*Copyright:Chao**History*----------------------*Rev:0.0*Date:20/08/2011**create.*----------------------*///---------------Includefiles-------------------------//#include<stc12c5a.h>#include"uart.h"//---------------FunctionPrototype-------------------------//#ifdefUART1_ENstaticvoiduart1_init(void);//串口1初始化函数staticvoiduart1_send_byte(unsignedcharddata);//串口1发送单个字符staticvoiduart1_send_string(unsignedchar*ddata,unsignedcharlength);//串口1发送字符串#endif#ifdefUART2_ENstaticvoiduart2_init(void);//串口2初始化函数staticvoiduart2_send_byte(unsignedcharddata);//串口2发送单个字符staticvo