📄 serial_port.c
字号:
/*
serial_port.c file
*/
#include "aduc841.h"
#include "serial_port.h"
#include "isr.h"
//*****************************************************************************************
void init_comport(void) //串口初始化函数,使用24M晶体,9600
{
EA=0;
TMOD=0x21; //定时器0工作在模式1,定时器1工作在模式2
SCON=0x50; //串口工作在模式1
TCON=0x05;
PCON=0x80; //串口波特率加倍
TH1=0x7E;
TL1=0x7E;
ES=1; //串行中断允许
TR1=1; //启动定时器1
REN=1; //允许接收
EA=1; //允许中断
}
//*****************************************************************************************
//*****************************************************************************************
void printc(unsigned char temp) //往串口发送一字节数据
{
sending=1;
SBUF=temp;
while(sending);
}
//*****************************************************************************************
/*void prints(unsigned char * temp,unsigned char line_feed)
{
while((*temp)!='\0')
{
send_to_comport(*temp);
temp++;
}
if(line_feed)
{
send_to_comport(13);
send_to_comport(10);
}
}
*/
/*void printf(unsigned long int x)
{
signed char i;
unsigned char display_buffer[10];
display_buffer[10]=0;
for(i=9;i>=0;i--)
{
display_buffer[i]='0'+x%10;
x/=10;
}
for(i=0;i<9;i++)
{
if(display_buffer[i]!='0')break;
}
for(;i<10;i++)printc(display_buffer[i]);
}*/
/*
void printc(unsigned char temp)
{
unsigned char i,j;
i=temp;
for(j=0;j<2;j++)
{
if(!j)i>>=4;
else i=temp&0x0F;
switch(i)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9: send_to_comport(i+'0');break;
case 10: send_to_comport('A');break;
case 11: send_to_comport('B');break;
case 12: send_to_comport('C');break;
case 13: send_to_comport('D');break;
case 14: send_to_comport('E');break;
case 15: send_to_comport('F');break;
default: break;
}
}
send_to_comport(' ');
}
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -