Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
771 Views

Help! my program can't work with nios ii on DE1 board

Hi,there! 

I built a nios project with the audio IP from university program IPs(version 10.1),and program as follow: 

 

int main(void) 

alt_up_audio_dev *audio_dev; 

unsigned int r_buf=1000; 

unsigned int l_buf=1000; 

unsigned int fifospace; 

 

audio_dev=alt_up_audio_open_dev("/dev/audio_controller"); 

if(audio_dev==NULL) 

printf("Error:could not open audio device\n"); 

else 

printf("Opened audio device\n"); 

while(1) 

fifospace=alt_up_audio_write_fifo_space(audio_dev,ALT_UP_AUDIO_RIGHT); 

if(fifospace>2) 

alt_up_audio_write_fifo(audio_dev, 

&(l_buf),2,ALT_UP_AUDIO_LEFT); 

alt_up_audio_write_fifo(audio_dev,&(r_buf),2,ALT_UP_AUDIO_RIGHT); 

 

return 0; 

I ensured that hardware connection was right,and a 18.4MHz clock signal from pll connected to wm8731 MCLK port,but when run as hardware in nios ii ide,no sound come out from line out port. I'm strongly puzzled.After looking for useful info in handbook pdf for a long time,found no. 

Can you help me? I'll sincerely appreciate that.
0 Kudos
3 Replies
Altera_Forum
Honored Contributor I
39 Views

Do you see "Opened audio device" in the console? 

I've ever used this component so I don't know if the code is right. I think you should use multiple word buffers instead of just unsigned ints. 

If your data size is 16 bits, what you are sending is a succession of 0 and 1000 values. This is a signal at a rather high frequency (half the sampling rate) and a rather low amplitude (about 1/32 of the maximum). So if it works it must be hard to hear. 

What word size and sampling frequency did you use?
Altera_Forum
Honored Contributor I
39 Views

Thanks for replying. I can see "Opened audio device" in the console window,and audio bit width is 16,and sampling rate is 48k sps. 

Are you familiar with the university program IP?
Altera_Forum
Honored Contributor I
39 Views

No I'm not, but to output any audio you will have to use buffers instead of just ints, and fill them with a signal such as a sine wave.

Reply