Errol, DMA seems to be made for such things. To be honest, I have no clue on how to setup a DMA channel for that. I haven’t yet read all chapters of the LPC24xx datasheet
A quick view tells me that it should be possible to let the DMA controller take bytes from a source buffer and copy them directly to the DAC register. But can’t see how you would implement a double-buffered functionality. I think you can only start a new transfer after the first is finished, and that might take too long, since it must happen within the sample playback period…
I’ll try it on Panda as soon as I get back from a business trip.
I’m working through your code. Do you want to share some things you discovered and how you did it? Looks like the bufer switching is happening in RLP. What role does MF play?
The NETMF just reads a stream from SD-card and fills a buffer when it needs to (flags are being polled on seperate thread).
The RLP code contains a double buffer that gets swapped when finished. A timer is firing an interrupt on the samplerate that sets a single sample on the DA converter.
@ Gus: It would have been nice to be able to trigger a DMA on a timer interrupt, but it doesn’t look like this architecture supports that. The DMA looks very restricted…
Think it was designed for I2S, but now, if i read the errata correctly, there is a bug with the I2S DMA and it is unusable…
Learning how to setup a timer and interrupt was on my to do list. Writing a word to the DAC register was a sur-plus. That’s why I jumped in here so quickly
Next on my to do list might be sampling the audio input on ADC and display a spectrum analyser using FFT on the LCD… We’ll see
I’m sorry to have to report that this doesn’t work on the Panda II.
The main reasons are:
TinyCore is required for the Dispatcher - and tinycore is not tiny. It uses almost 64k ROM - which then doesn’t fit on the Panda together with the ELF resource (and everything else). I’m working through the code to understand how the Dispatcher is used and if there is an alternative.
The ELF file doesn’t load from the resource file. It first wants to transfer to memory and there isn’t enough on the Panda. I’ll have a look at the other examples to load directly from SD or flash or load it earlier in the program as suggested on the RLP page.
I’m not sure if the RLP for the Cobra is going to work on the Panda. It looks like the memory offsets are different. Haven’t got this far - but I’ll report back if I do.
Wouter: I’ll be happy to work with you to make changes for this on the Panda - but I’m not as clued-up on RLP as you are, so you’ll have to guide me here on how I can help.
@ realiser: that Dispatcher thing is just to fire the PlaybackFinished event asynchronous. You can remove those events from the code if you like.
You might have to load the ELF file from SD. I’m not familiar with the smaller Panda, but I might receive one in near future, I will then try to run and eventually modify the code…
I downloaded the sample and ELF a week ago and am having problems with it. To be honest, I have not tried a standalone test app to see if the code works on its own.
However, in my app (running on a FEZ Cobra) I use the 3.5" LCD and also load another ELF with code that manipulates an ADC port and uses the RLP task scheduler. I also modified the C# code by adding a ‘Play’ method that takes a buffer that I load from resources.
When ‘Play’ is called, it calls ‘Stop’ which calls the RLP Deinit method. The FEZ Cobra crashes at this point. If I remove the Deinit call since Init was never called before, the FEZ Cobra freezes at the Init call in the ‘Play’ method.