中文字幕无码不卡一区二区三区_少妇被又大又粗又爽毛片久久黑人_91精品国产在热久久无毒不卡_久久久久久亚洲综合网站

技術(shù)熱線: 4007-888-234
設(shè)計開發(fā)

專注差異化嵌入式產(chǎn)品解決方案 給智能產(chǎn)品定制注入靈魂給予生命

開發(fā)工具

提供開發(fā)工具、應(yīng)用測試 完善的開發(fā)代碼案例庫分享

技術(shù)支持

從全面的產(chǎn)品導(dǎo)入到強(qiáng)大技術(shù)支援服務(wù) 全程貼心伴隨服務(wù),創(chuàng)造無限潛能!

新品推廣

提供新的芯片及解決方案,提升客戶產(chǎn)品競爭力

新聞中心

提供最新的單片機(jī)資訊,行業(yè)消息以及公司新聞動態(tài)

音樂程序示例

更新時間: 2019-03-22
閱讀量:1785

十年單片機(jī)開發(fā)方案公司深圳英銳恩分享音樂程序示例。

采用TMR1中斷作音符發(fā)聲,TMR0作音長節(jié)拍。

const byte music_15[]={0xfa,0x67,0xfb,0x03,0xfb,0x90,0xfc,0x0c,0xfc,0x44,
 
     //  2         3         4         5         6
        0xfc,0xac,0xfd,0x09,0xfd,0x34,0xfd,0x82,0xfd,0xc8,
       
     //     *         *         *         *         *
     //  7         1         2         3         4    5
        0xfe,0x06,0xfe,0x22,0xfe,0x56,0xfe,0x85,0xfe,0x98,0xfe,0xc1};

//梁祝
const byte M_MUSIC[79]=
{
 0x23,0x42,0x50,0x72,0x80,0x50,0x70,0x41,0xb2,0xe0,0xc0,0xb0,0x90,0xb0,0x87,
 0x81,0x80,0x90,0x61,0x51,0x42,0x50,0x71,0x81,0x21,0x71,0x50,0x40,0x50,0x70,
 0x47,0x92,0xb0,0x61,0x81,0x50,0x70,0x41,0x43,0x20,0x40,0x21,0x40,0x50,0x60,
 0x80,0x55,0x40,0x50,0x72,0x80,0xb1,0x91,0x81,0x90,0x80,0x71,0x50,0x40,0x23,
 0x73,0x50,0x70,0x50,0x40,0x20,0x40,0x50,0x70,0x46,0x90,0xb0,0x80,0x90,0x80,
 0x70,0x61,0x51,0x47
};

const byte M_MUSIC1[100]=
{

0xd0,0xc0,0xd0,0xf0,0xc0,0xd0,0xb0,0xa0,0x90,0x80,0x90,0xb0,0x82,0x70,
 0x61,0x91,0x80,0x70,0x60,0x50,0x47,
 0x91,0x90,0xb0,0x60,0x80,0x50,0x60,0x80,0x60,0x81,0x43,0xb1,0x91,0xd0,
 0xf0,0xc0,0xd0,0xd1,0xb5,0xb2,0xc0,0xd1,0xf0,0xd0,0xc1,0xa1,0x91,0x81,
 0x91,0x90,0xb0,0x60,0x80,0x50,0x60,0x80,0x60,0x85,0xb1,0xb0,0x90,0x80,
 0x90,0xb0,0xa0,0x91,0x93,0x80,0x90,0xb1,0xb0,0x90,0x80,0x90,0xb0,0xa0,
 0x91,0x93,0x80,0x90,0x91,0x90,0xb0,0x80,0x90,0xb0,0xa0,0x92,0xb0,0x81,
 0x61,0x81,0x60,0x80,0x50,0x60,0x80,0x70,0x67
};

//繡金匾_序曲
const byte M_MUSIC2[51]=
{
 0xd0,0xc0,0xb0,0x90,0xc1,0xb0,0x90,0xb0,0xc0,0xd1,0xd0,0xc1,0xb0,0x93,0x63,
 0x61,0xc0,0xb0,0xc1,0xd1,0xb0,0xb0,0x90,0xb0,0xc3,0xd1,0xd0,0xc0,0xb1,0xc1,
 0x91,0xd0,0xc0,0xc0,0xb0,0x91,0x61,0xc0,0xb0,0xc1,0xd1,0x91,0x81,0x63,0xc2,
 0xd0,0xb0,0x90,0x80,0xb0,0x97
};

//********************** 中斷服務(wù)程序 ********************************************
//聲音產(chǎn)生.
//*******************************************************************************
void interrupt time_mu(void)
{
//TMR1做聲音
 TMR1L=m_music_L;  //重置計時器初值,以產(chǎn)生一定頻率
 TMR1H=m_music_H;
 TMR1IF=0;
 if(!stop_f)
  SOUND=!SOUND;
}

//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
//  上電初始化
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
void  init(void)
{
 TRISA=0xff;
 TRISC=0; //
 PORTC=0;
 T1CON=1;  // 1/1 timer1 on
 TMR1IF=0;
 TMR1IE=1;
 PEIE=1;

OPTION=0x88;
 CMCON=0xff; 
 T0IF=0; //清除TMR0的中斷標(biāo)志
 INTF=0; //清RB0中斷
 T0IE=0; //TMR0中斷允許
 GIE=1; //總中斷允許
 RFstate=0;
}

fSYS()
{
 if(testbit(TMR0,7))
 {
  clrbit(TMR0,7);
  recver();
  ms_64++;
  if(ms_64==0)

 {
   fre_time++;
   if(fre_time==m_music_long_temp)
   {
    ONE_S_F=0;
    fre_time=0;
    stop_f=0;
   }
  }
 }

//************************ 主程序 *************************//
void main()
{
 init();
 ONE_S_F=0;
 while(1)
 {
  stop_f=0;
  for(n=0;n<79;)
  {
   if(!ONE_S_F)
   {
    s_reg=M_MUSIC[n]&0x0f;
    m_music_long=music_long[s_reg];
    m_music_long_temp=(m_music_long<<1);
    s_reg=(((M_MUSIC[n]&0xf0)>>4)<<1);
    m_music_H=music_15[s_reg];
    TMR1H=m_music_H;
    s_reg++;

  m_music_L=music_15[s_reg];
    TMR1L=m_music_L;
    ONE_S_F=1;
    n++;
   }
   fSYS();   
  }

  for(n=0;n<100;)
  {
   if(!ONE_S_F)
   {
    s_reg=M_MUSIC1[n]&0x0f;

   m_music_long=music_long[s_reg];
    m_music_long_temp=(m_music_long<<1);
    s_reg=(((M_MUSIC1[n]&0xf0)>>4)<<1);
    m_music_H=music_15[s_reg];
    TMR1H=m_music_H;
    s_reg++;
    m_music_L=music_15[s_reg];
    TMR1L=m_music_L;
    ONE_S_F=1;
    n++;
   }
   fSYS();   
  }
  
  for(n=0;n<51;)
  {
   if(!ONE_S_F)
   {
    s_reg=M_MUSIC2[n]&0x0f;
    m_music_long=music_long[s_reg];
    m_music_long_temp=(m_music_long<<1);
    s_reg=(((M_MUSIC2[n]&0xf0)>>4)<<1);
    m_music_H=music_15[s_reg];
    TMR1H=m_music_H;
    s_reg++;
    m_music_L=music_15[s_reg];
    TMR1L=m_music_L;
    ONE_S_F=1;
    n++;
   }
   fSYS();   

(文源網(wǎng)絡(luò),侵刪)

日喀则市| 石家庄市| 治多县| 鞍山市| 五寨县| 腾冲县| 宝坻区| 瑞昌市| 高邑县| 翁牛特旗| 厦门市| 华池县| 富川| 剑阁县| 丰宁| 清远市| 阜新市| 西峡县| 兰州市| 宜都市| 榆社县| 济宁市| 新巴尔虎右旗| 龙州县| 竹北市| 麟游县| 宜宾县| 天台县| 光山县| 新昌县| 泾源县| 托克托县| 巢湖市| 洪江市| 集安市| 泰州市| 安吉县| 大竹县| 永丰县| 礼泉县| 商洛市|