欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
自學51單片機,關于串口通信中斷程序問題
[打印本頁]
作者:
小菜鳥啦啦啦
時間:
2019-8-21 10:05
標題:
自學51單片機,關于串口通信中斷程序問題
波特率4800,smod置1翻倍,串口中斷里的switch 語局直接跳過,也能在 pc上看到收發的數子。
單片機源程序如下:
#include<reg51.h>
#include<intrins.h>
#define led P2
typedef unsigned char u8;
typedef unsigned int u16;
sbit LLa=P2^2;
sbit LLb=P2^3
;sbit LLc=P2^4;
sbit beep=P1^5;
u8 code a[]={ 0x3f , 0x06 , 0x5b , 0x4f , 0x66 , 0x6d , 0x7d , 0x07 , 0x7f , 0x6f , 0x77 , 0x7c, 0x39 , 0x5e , 0x79 , 0x71 };
void delay (u16 i)
{ while (i--);}
void fengmingqi ()
{ u16 i=1000;
while (i)
{ beep=~beep; delay(100) ;i--; }}
void shuomaguan ()
{ u8 i;
LLa=1;
LLb=1;
LLc=1;
for (i=0;i<16;i++)
{ P0=a[i]; delay(50000) ; }}
void ledshanguang()
{ u8 i;
led=0xfe;
delay(50000);
while (1) {
for (i=0;i<7;i++)
{ led=_crol_(led,1); delay(50000); }
for (i=0;i<7;i++)
{ led=_cror_(led,1); delay(50000); } }}
void chuankouint()
{ TMOD=0X20; TH1=0XF3; TL1=0XF3; SCON=0X50; PCON=0X80; EA=1 ; ES=1 ; TR1=1 ; }
void main() /***********主函數**********/
{
chuankouint();
while(1) ; }
chuankouzhongduan() interrupt 4 {
u8 b;
b=SBUF;
RI=0;
switch (B)
{ case 1:ledshanguang();break;
case 2:shuomaguan();break;
case 3:fengmingqi();break; }
SBUF=b;
while(!TI);
TI=0;
}
復制代碼
作者:
csmyldl
時間:
2019-8-26 02:07
switch (B)中括號里的B應為小寫,不知你程序編譯通過沒有,直接跳過此語句也能收到是因為串行中斷里有發送程序:SBUF=b;
while(!TI);
TI=0; 每進入一次串行中斷,均會把當前的b中內容發送回去,所以能看到數據。
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1