# [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
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;

delay_ms(400);

}
}

// 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.

Replies
8
Views
1K
Replies
21
Views
3K
Replies
3
Views
833
Replies
1
Views
1K
Replies
3
Views
726