Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[AVR] About delay ued between playback of two different files on STK600 using PWM

Status
Not open for further replies.

Mandar Joshi

Member level 2
Joined
Mar 4, 2015
Messages
50
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
445
I am using STK600 on which I am using PWM for sound generation. I play wav files by reading data from eeprom. When I play single file it works fine.

But when I try to play two different files it doesn't work properly. i.e.



1. If I give two consecutive function calls for reading data from eeprom and putting on OCR1A(Match Register) register then I can hear only second file.

2. If I give some delay between two function calls I can hear both the files properly.



The delay which I use is delay_ms(400) which makes my program work properly but at the same time it holds entire program execution which may cause trouble. Is there any solution for this trouble??

And what is reason behind improper functioning of code without introducing this delay??



The main() function is as follows:


Code:
int main (void)
{
 // Insert system clock initialization code here (sysclk_init()).

  board_init();
	
  init_timer();
	
  init_uart();
  
  tx_clk();
  
  spimstr_init();
  
  init_pwm();
  	
  while(1)
 {
   key();
	
   if(key_status==key_pres)
  {
	if(playback_cmplete)
	
		key_status=no_key_pres;
		
	h=hr;
	
	m=min;
	
	continuous_pg_read(start_addr[h],0x00,wav_len[h]);  //Function call to play first wav file
	
	delay_ms(400);                                      
	
	continuous_pg_read(start_addr[m],0x00,wav_len[m]);  //Function call to play second wav file
   }	
  }
 
    // Insert application code here, after the board has been initialized.
}

If I remove delay_ms(400) call then it doesn't work properly.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top