把我用的串口通讯程序(中断方式)搭个便车让大家看看,并非原创,从<<嵌入式系统构件>>的相关代码移植而来。
#include "../inc/includes.h"
char xdata ser_buffer[SERIAL_BUFF_SIZE]; /* the receive buffer*/
int ser_end = -1;
int ser_start=-1; /* indexes into receive buffer*/
int ser_ch;
int char_ready=0; /* current character and ready flag*/
int serial_lock = 0; /* serial ISR semaphore so the buffer*/
/* isn't altered will it is being written*/
//功能介绍:串口通讯中断服务程序。
//入口参数:无
//出口参数:无
//备注:系统开中断后由中断触发执行。
void Serial_Isr(void) interrupt 4
{
/* this is the ISR (Interrupt Service Routine) for the com port. It is very*/
/* simple. When it gets called, it gets the next character out of the receive*/
/* buffer register 0 and places it into the software buffer. Note