Haberler:

Foruma Resim Yükleme ve Boyut Sınırlaması ( ! )  https://bit.ly/2GMFb8H

Ana Menü

CCS c de müzik yükleme

Başlatan bbs2006, 16 Mart 2009, 16:34:55

bbs2006

Merhaba
CCS c de yazılmış müzik notalrını nerden bulabilirim. Yardımcı olursanız sevinirim.

TAYM

/******************************************************************
PIC16F877 ile Ses Uygulaması
*******************************************************************/
#include <16f877A.h>     // Kullanılacak denetleyicinin başlık                 // dosyası tanıtılıyor.
//#fuses XT,NOWDT,NOPROTECT//,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NOCPD //NODEBUG, Denetleyici konfigürasyon ayarları

#use delay (clock=4000000) // Gecikme fonksiyonu için kullanılacak osilatör frekansı belirtiliyor.

#include <TONES.c>  // TONES.c dosyası programa ekleniyor

// Ses tonlarından oluşan dizi tanımlanıyor
const char muzik[48]={C_NOTE[0],C_NOTE[1],C_NOTE[2],C_NOTE[3],Db_NOTE[0],Db_NOTE[1],Db_NOTE[2],Db_NOTE[3],
                   D_NOTE[0],D_NOTE[1],D_NOTE[2],D_NOTE[3],Eb_NOTE[0],Eb_NOTE[1],Eb_NOTE[2],Eb_NOTE[3],
                   E_NOTE[0],E_NOTE[1],E_NOTE[2],E_NOTE[3],F_NOTE[0],F_NOTE[1],F_NOTE[2],F_NOTE[3],
                   Gb_NOTE[0],Gb_NOTE[1],Gb_NOTE[2],Gb_NOTE[3],G_NOTE[0],G_NOTE[1],G_NOTE[2],G_NOTE[3],
                   Ab_NOTE[0],Ab_NOTE[1],Ab_NOTE[2],Ab_NOTE[3],A_NOTE[0],A_NOTE[1],A_NOTE[2],A_NOTE[3],
                   Bb_NOTE[0],Bb_NOTE[1],Bb_NOTE[2],Bb_NOTE[3],B_NOTE[0],B_NOTE[1],B_NOTE[2],B_NOTE[3]   };

int i;  // Tam sayı tipinde değişken tanımlanıyor

//******************* ANA PROGRAM FONKSİYONU *******************
void main ()
{
  setup_psp(PSP_DISABLED);        // PSP birimi devre dışı
  setup_spi(SPI_SS_DISABLED);     // SPI birimi devre dışı
  setup_timer_1(T1_DISABLED);     // T1 zamanlayıcısı devre dışı
  setup_timer_2(T2_DISABLED,0,1); // T2 zamanlayıcısı devre dışı
  setup_adc_ports(NO_ANALOGS);    // ANALOG giriş yok
  setup_adc(ADC_OFF);             // ADC birimi devre dışı
  setup_CCP1(CCP_OFF);            // CCP1 birimi devre dışı
  setup_CCP2(CCP_OFF);            // CCP2 birimi devre dışı

  output_low(pin_b0); // RB0 çıkışı ilk anda lojik-0

  while(1) // Sonsuz döngü
  {
     for(i=0;i<48;i++)
     {
        generate_tone(muzik,100); delay_ms(50); // Sırayla muzık[] dizisindeki
     }                                             // tonlar oluşturuluyor
 }
}

ilker_32

Bir uygulama daha CCS C dosyaları içinde mevcut olması gerekir.

ses çıkışı portb.0

/////////////////////////////////////////////////////////////////////////
////                          EX_TONES.C                             ////
////                                                                 ////
////  This example plays the song "Happy Birthday."                  ////
////                                                                 ////
////  Configure the CCS prototype card as follows:                   ////
////     Connect the positive wire of the speaker to pin B0          ////
////     Connect the negative wire of the speaker to Gnd             ////
////                                                                 ////
////  This example will work with the PCM and PCH compilers.  The    ////
////  following conditional compilation lines are used to include a  ////
////  valid device for each compiler.  Change the device and clock   ////
////  pins for your hardware if needed.                              ////
/////////////////////////////////////////////////////////////////////////
////        (C) Copyright 1996,2003 Custom Computer Services         ////
//// This source code may only be used by licensed users of the CCS  ////
//// C compiler.  This source code may only be distributed to other  ////
//// licensed users of the CCS C compiler.  No other use,            ////
//// reproduction or distribution is permitted without written       ////
//// permission.  Derivative programs created using this software    ////
//// in object code form are not restricted in any way.              ////
/////////////////////////////////////////////////////////////////////////


#if defined(__PCM__)
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)

#elif defined(__PCH__)
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#endif

#include <tones.c>

#define SIZE 25

const struct note
{
   long tone;
   long length;
} happy_bday[SIZE] = {
C_note[0],350, C_note[0],100, D_note[0],500, C_note[0],500, F_note[0],500, E_note[0],900,
C_note[0],350, C_note[0],100, D_note[0],500, C_note[0],500, G_note[0],500, F_note[0],900,
C_note[0],350, C_note[0],100, C_note[1],500, A_note[0],500, F_note[0],500, E_note[0],500, D_note[0],900,
Bb_note[0],350, Bb_note[0],100, A_note[0],500, F_note[0],500, G_note[0],500, F_note[0],1200};


void main(void)  {
   int i;

   while(TRUE)
   {
      for(i=0; i<SIZE; ++i)
      {
         generate_tone(happy_bday[i].tone,happy_bday[i].length);
         delay_ms(75);
      }
   }
}