标题:请问一下这段程序实现了什么功能啊,这是基于51单片机的音乐播放器里的一段 ...
取消只看楼主
小澡
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2020-3-16
结帖率:0
 问题点数:0 回复次数:1 
请问一下这段程序实现了什么功能啊,这是基于51单片机的音乐播放器里的一段程序,有大佬能帮忙讲解一下吗,具体一点就更好了,谢谢
void SendASC(uchar d)
{
   
    SBUF=d;
    while(!TI);     //

    TI=0;
}
void SendString(uchar *str)         
{
    while(*str!='\0')                       
    {
        SendASC(*str) ;           
        str++;                  
    }
}

//  通讯中断接收程序   中断函数无返回值
  void uart_rx(void)  interrupt 4    using 3      
 {

       unsigned char i;
    unsigned char flag;
    unsigned char dat;
    if(RI)                     //是否接收中断     RI是接受中断请求标志位
    {
      
       RI=0;
       dat=SBUF;
       if(dat==0xc1) //接收数据第一帧
       {
            buff[0]=dat;
            flag=1;        //开始接收数据
       }
       else if(dat==0xc5)
       {
              buff[0] = dat;
              flag=2;
              i=1;
       }
       else if(dat==0xc9)
       {
              buff[0] = dat;
              flag=3;
              i=1;
            
       }
        else if(dat==0xc2)
       {
              buff[0] = dat;
              flag=4;
              i=1;
            
       }
       else
       {
           switch (flag)
           {   case 1:     flag=0;
                          yinliang= dat;
                       break;
                case 2:      if(i==1) i++;
                           else
                           {
                             flag=0;
                        
                             zongqumu=dat;
                           } break;
                case 3:         if(i==1) i++;
                           else
                           {
                             flag=0;
                          
                             dangqianqumu=dat;
                           }
                        
                             break;
              case 4:   flag=0;zhuangtai=dat;break;
            }
        }   
     }

 }
 

#endif
            
搜索更多相关主题的帖子: break flag dat case 中断 
2020-03-28 15:49
小澡
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2020-3-16
得分:0 
求大神指导
2020-03-28 21:30



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-500679-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.309830 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved