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

技術熱線: 4007-888-234

技術支持

音樂程序示例

更新時間: 2019-03-22

十年單片機開發(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
};

//********************** 中斷服務程序 ********************************************
//聲音產(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的中斷標志
 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)絡,侵刪)

404
返回首頁 |  返回上一頁
晋州市| 新蔡县| 泗洪县| 昭苏县| 黄陵县| 永城市| 旬阳县| 中超| 德令哈市| 大同市| 翼城县| 石阡县| 田东县| 光泽县| 黄梅县| 米易县| 涟源市| 怀宁县| 镇坪县| 扶风县| 苍梧县| 肇东市| 云林县| 五常市| 汕尾市| 内乡县| 都兰县| 彝良县| 喀什市| 贵阳市| 类乌齐县| 东兰县| 筠连县| 天津市| 宁都县| 天台县| 临汾市| 万山特区| 田林县| 安新县| 德庆县|