Run Speaker With USB 2.0 Stack
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am working on SDK2.0 USB stack forK22 series micro-controllers.
My aim is to read .mp3 files from mass storage device and play it on speakers, so want the information.
I know that audio files are sent over Isochronous transfer type and i am using USB_HostAudioStreamSend() function send audio data. So the question is do i have to create timer of 125us and call USB_HostAudioStreamSend() function again to send complete data or callback function is called after 125us?
if i am missing something please let me know. Just want to know how implement in my code.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Buffer max is 192. I can read in gpacketsize variable when it's enumerated.
Where in the code SOF is transmitted every 1ms? Cause PCM2706 works in sync with SOF.
Regards,
Aniket
Get Outlook for Android<https://aka.ms/ghei36>


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
It seems K22 will generate SOF automaticly. Attachment is the timing diagram of K22_USB_host_audio_speaker.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jing Pan,
Thank you for information.
If SOF is sent automatically, is there any way to synchronize the transfer of audio stream with SOF in the stack?
Regards,
Aniket


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You can see from the picture that audio stream has synchronize with SOF already. I think this is because the program is driven by the interrupt from SOF.
Regards
Jing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
okay. Which code you have tried, can you please tell me?
And if you have any sample code to play wav files that will be great help.
Regards,
Aniket


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I tried twrk22f120m_usb_example_usb_host_audio_speaker_bm. Yes, this is.
Regards
Jing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
In this demo code the data is not sent periodically, like every 1ms using any timer or something as u suggested in earlier post.
Let me know if i am missing something.
Regards,
Aniket


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Yes, it seems you don’t need to add another timer. The demo already send a packet on every SOF.
During my test, I found that the voice length is determined by device’s descriptor in twrk22f120m_usb_example_usb_host_audio_speaker_bm. But in my device code, the value is buffer length. It is wrong if I send so many samples to device. So you should take care about it.
Regards
Jing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jing Pan,
I used the logic analyzer to see the data and what might be going wrong. I see that sometimes error packets are being transmitted every 1ms.(number of error packets varies) instead of audio data.
What might be the reason for it? Please suggest something.
PS: others can answer too.
Regards,
Aniket


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Aniket,
Yes, I also found a strange error. It is SOF length error. But it seems doesn't matter. It is still a valid packet. In fact I don't understand what is wrong. Is it what you see?
Regards
Jing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jing pan,
Please Find attached image of data i have captured.
Its seems like lot of jitter in USB clock. Please have a look and let me know.
CH3 and CH4 are from controller.
CH5 and CH6 are from hub to speaker DAC IC.
Regards,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jing Pan,
I tried reading full file from MSD at once in large buffer(uint8_t array[45000]) and then play. It played perfectly.
But in actual scenario i cant have such large buffer, so i am reading 1152 bytes at time in a buffer from file which is in MSD and sending 64 bytes every 1ms and in parallel i am trying to read another 1152 bytes in another buffer. When first buffer is completely sent i switch to second buffer to send audio data every 1 ms and in parallel next 1152 bytes are read in first buffer. Is something wrong with this logic?
I also observed that when i try to read from file when playing sound, all problems are happening. Please suggest something. In above comments i have attached audio_speaker.c for reference..
Expecting reply soon
Regards,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please reply ASAP, URGENT!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you :smileyhappy:
I will post to TI about the issue.
Regards,
Aniket


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Since you are host, can you read back the usb speaker's information?
Regards
Jing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jing Pan,
If you tell me exactly what information, i will provide you here. I see that i get that speaker supports 32Khz, mono channel in audio structures.
Also in function USB_AudioTask(), when case "kRunAudioSetCurSamplingFreq" is executed and Audio_ControlCallback is called, status is not "kStatus_USB_Success", getting "kStatus_USB_TransferStall". Other switch cases are successful.
Is that might be the problem?
What is the reason for kStatus_USB_TransferStall and how to resolve it. DAC chip used is PCM2706C.
Regards,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
reply asap. thank you


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi aniketmarkande,
Wave file is signed data. But USB stack dont care data format. So don't worry about it. I think your problem is on bitrate. I think you may adjust sample number in each packet. If the samplerate is 32000 and you send data each 1ms, you should only put 32000/1000=32 samples in a packet.
Regards
Jing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jing Pan,
Thank you for your response. :smileyhappy:
32 samples per seconds i tried sending, its plays too slow. Since wav file has PCM 16 bit data, i am sending 64 bytes every 1 ms and plays without noise(pattern of the tone is correct). But the audio does not sound exactly as it sounds on pc, sounds little harsh. It will be great help if you can share some information how to do solve this problem. (sorry i am not able to explain exactly whats the problem)
Also i am using USB interrupt for sending to send every 1ms. (i hope this is correct).
I tried 1 ms timer but it does not play well as sound chip plays data on when it received SOF.
Waiting for your response.
Regards,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please help out, running out of time.
Thank you
