VS1053 using DREQ as an interrupt

Writing software that inputs and/or outputs audio and performs DSP algorithms such as filters, new codecs or audio effects.
Post Reply
zulunation
User
Posts: 15
Joined: Mon 2012-02-06 23:04

VS1053 using DREQ as an interrupt

Post by zulunation » Tue 2016-02-02 15:22

Hello,
I'm using VS1053 decoder.
In my design there is a ARM which controls vs1053.
I want to use DREQ as an interrupt source but i think this will not be time effective.
According to datasheet when DREQ goes high we can write at least 32 bytes of data.
This is too little to write for one interrupt.
As i understand when FIFO is full DREQ goes low. When there is 32 bytes of data available DREQ will go high.
That means if i use DREQ as an interrupt source and write data on interrupt the interrupt rate will be very high and this will be not time effective.
My ARM is powerful enough but it will waste time on adding 32 bytes of data each time.
It would be nice if DREQ could signal that FIFO is 50% empty. But that is impossible as i understood.
Am i correct about what i wrote?

User avatar
Panu
VLSI Staff
Posts: 2354
Joined: Tue 2010-06-22 13:43

Re: VS1053 using DREQ as an interrupt

Post by Panu » Tue 2016-02-02 15:40

Yes... there's a so many postings in this board about this, covering your various possibilities. See for example viewtopic.php?f=7&t=1779&p=8745&hilit=DREQ#p8745 and viewtopic.php?f=11&t=1793&p=8837&hilit=DREQ#p8837. The 32-byte limit is hardcoded very deep into the IC and it was quite reasonable at the time the VS10XX chips were first developed, when there was no multitasking and people used hardware interrupts, sometimes written in assembly in microcontrollers of the age. Your best bet might be to use the DREQ as interrupt source, but instead of fixing the transfer amount to 32 bytes, read how much free space there actually is in the stream buffer and send that amount. Pls. see the above post links to find out how to get the buffer fill state.

-Panu
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo, VLSI Solution Oy

zulunation
User
Posts: 15
Joined: Mon 2012-02-06 23:04

Re: VS1053 using DREQ as an interrupt

Post by zulunation » Tue 2016-02-02 19:14

Thanks,

I have looked through the links. I can get the fill state but if i do this in the interrupt on the DREQ i will get a value close to 32 bytes or maybe 10-20 % more. My CPU is very powerful. So in that case the DREQ interrupts will trigger too often. That is not time efficient.
I see two solutions to that problem.
1. To put one CPU ONLY for data streaming. Another CPU will do other job.
2. After starting the streaming launch a timer. If bitrate of the file is known so we can calculate how much time it will take to get the buffer 50% empty. Let say it is T. Configure timer to trigger interrupts each T time. On the interrupt fill the buffer using DREQ as a indicator of the buffer FULL state.

What do you think about my ideas?

User avatar
Panu
VLSI Staff
Posts: 2354
Joined: Tue 2010-06-22 13:43

Re: VS1053 using DREQ as an interrupt

Post by Panu » Wed 2016-02-03 1:03

if i do this in the interrupt on the DREQ i will get a value close to 32 bytes or maybe 10-20 % more.
That's not exactly true, because VS10XX will take bytes out from the buffer on a block by block basis, so also you will get an interrupt on a block by block basis. The size of the block is different for each codec. For MP3 it's a few hundred bytes per block.

If your CPU has no load, you will get interrupts often. But since your CPU is not doing anything else at that moment, it shouldn't be a problem. If your CPU has more load because it is doing other stuff, disable interrupts for the duration for the other stuff so you get interrupts less often. A timer in your CPU can be helpful. Or you can configure your timer to do 50 interrupts per second and always fill the stream buffer during each interrupt, that should solve the problem.

Another possibility is to not use interrupts or multitasking at all. That's probably the most common solution.
2. After starting the streaming launch a timer. If bitrate of the file is known so we can calculate how much time it will take to get the buffer 50% empty. Let say it is T. Configure timer to trigger interrupts each T time. On the interrupt fill the buffer using DREQ as a indicator of the buffer FULL state.
It depends on which format you are playing. For MP3 it's ok but for WMA you need to keep the stream buffer full because WMA can have blocks that are nearly as large as the stream buffer itself.
That is not time efficient.
I'd argue that overall efficiency is not very interesting. It's more important to get a worst-case performance good enough that you don't get any gaps in the sound. And as I said, as VS10XX takes bytes from the buffer in a block-by-block basis, you will also get interrupts in a block by block basis if you always fill the whole buffer.

If I was doing it and I would come to the conclusion that I need to do the data transfer in an interrupt, I'd probably do the whole thing in a timer interrupt, 50 times per second. For MP3, even less often would be ok.

-Panu
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo, VLSI Solution Oy

User avatar
pasi
VLSI Staff
Posts: 1355
Joined: Thu 2010-07-15 16:04

Re: VS1053 using DREQ as an interrupt

Post by pasi » Wed 2016-02-03 14:41

It depends on the decoder how many bytes will be read from the FIFO at once. The mp3 decoder reads whole mp3 frames, most other decoders decode their bitstream directly from the stream buffer (SDI FIFO), so they can 'free' any number of words in irregular intervals.

Not all formats are constant or near-constant bitrate, but if your transfers are fast, checking just often enough would probably work fine.

I think you could try a fixed delay from the moment DREQ goes high to when you check for the fill state of the SDI FIFO.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

zulunation
User
Posts: 15
Joined: Mon 2012-02-06 23:04

Re: VS1053 using DREQ as an interrupt

Post by zulunation » Wed 2016-02-03 18:39

Thanks for help,

Post Reply

Who is online

Users browsing this forum: No registered users