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:
If I remove delay_ms(400) call then it doesn't work properly.
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.