?? exp8.c
字號:
#include <io8535.h>
#include <intrinsics.h>
void sendmsg(char *s)
{
qcntr=0; //預先設置索引
sndcntr=1; //設置為1,因為第一個字符已經發送
queue[qcntr++]=0x0d; //將CRLF放到隊列的頭
queue[qcntr++]=0x0a;
while(*s)
queue[qcntr++]=*s++; //將字符放入隊列
UDR=queue[0]; //發送第一個字符到起始程序
}
void main(void)
{
UCR=0x58; //使能接收、發送及數據傳輸中斷
UBRR=0x33; //設置波特率為9600
__enable_interrupt(); //設置全局中斷使能
while(1)
{
if(USR&0x80) //檢測,并接收字符
{
ch=UDR; //將字符發送到pc機
switch(ch)
{
case 'a'
sendmsg(msg1); //發送第一條信息
break;
case 'b'
sendmsg(msg2); //發送第二條信息
break;
default:
sendmsg(msg3); //發送默認信息
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -