Hello,
I am new here. I am using ATMEL STUDIO 7.0 and using an ATMEGA 1284. I am following the tutorial from http://aquaticus.info/pwm-music. When I load their code onto the ATMEGA 1284 the buzzer just make a lot of
fast tapping noises. I have tried fixing the code by trying out the recommendations from one of the people that commented which is pasted below. It was still a bunch of tapping with some delay. What can I do to fix this?
. void PlayMusic( const int* pMusicNotes /** Pointer to table containing music data */, uint8_t tempo /** paying tempo from 0 to 100. Higher value = slower playback*/ ) { int duration; int note; int i; uint16_t delay = tempo * 10000; while( *pMusicNotes ) { note = *pMusicNotes; pMusicNotes++; duration = *pMusicNotes; pMusicNotes++; if( p == note ) { //pause, do not generate any sound OCR1B = 0; } else { //not a pause, generate tone OCR1B = DEFAULT_VOLUME; //set frequency ICR1H = (note >> 8); ICR1L = note; } //wait duration for(i=0;i<32/duration;i++) { _delay_loop_2( delay ); _delay_loop_2( delay ); _delay_loop_2( delay ); _delay_loop_2( delay ); _delay_loop_2( delay ); } } //turn off any sound OCR1B = 0; }