Forums » Software Development »
Using dspQDMA library on OMAP-L138
Added by Rich Bagdazian about 13 years ago
I am using the dspQDMA class in a project on the mity-omap processor. I was able to successfully load all of the components and successfully link my project for the dsp. When I execute the dspQDMA->ReadFromFIFO routine (I am reading data from a single fixed address in CS5 space which is a fifo that we have implemented in VHDL) data appears to be read correctly. My problem seems to be that when I issue a SEM_pend request on the supplied semaphore to wait for the DMA operation to complete, the pend operation falls through even though the DMA operation has not completed execution. I am running the dspQDMA->ReadFromFIFO request inside of a timer routine which is scheduled off of the PRD interrupt executing every 5ms. Shouldn't the pend operation block until the dma operation completes? Are there restrictions on using the dma operations inside of timer schedule routines?
Thanks,
Richard
Replies (7)
RE: Using dspQDMA library on OMAP-L138 - Added by Michael Williamson about 13 years ago
Hi Richard,
How are you creating the Semaphore? Zero initialization value?
Is it possible your routine that is pending is running slower than the 5 ms PRD timer (and you are effectively falling behind)? Are your timer routines running under interrupt service contexts (it shouldn't matter, just curious). You cannot pend on a semaphore from within an ISR, I am assuming you have a separate thread that is running the pend routine?
I will check with some users of this code here and try to see if they are using the semaphore notification feature and get back to you.
-Mike
RE: Using dspQDMA library on OMAP-L138 - Added by Rich Bagdazian about 13 years ago
Hi Mike,
I will check on the initialization value. I was calling the SEM_pend function immediately after requesting the DMA operation initially so that I wouldn't leave the routine before the transfer had completed. The last question was one that may have some bearing. I was calling the SEM_pend inside of the 5ms routine. I wasn't clear on whether that would effectively be running at interrupt level or not.
Thanks,
rich
RE: Using dspQDMA library on OMAP-L138 - Added by Rich Bagdazian about 13 years ago
If I did want to be sure that the operation had completed before moving on, is there an alternative approach. In this case polling would probably be ok, but I didn't see any methods in the class to support polling.
-rb
RE: Using dspQDMA library on OMAP-L138 - Added by Michael Williamson about 13 years ago
If you are calling SEM_pend() from within an ISR, you need to use a zero timeout. You could do a
while(SEM_pend(sem,0)) {}type loop to poll for completion. However, if the priority of the PRD ISR is higher than the ISR that is handling the transmit completes from the EDMA wrapper, then the EDMA ISR isn't going to get a chance to run and this could pose a deadlock risk.
For the type of processing you are doing, we normally decouple the processing phase from the data collection phase (and ping-pong the input data) in order to allow overlap of the data capture and the processing. E.G., kick the EDMA off in the PRD ISR, then run a high priority thread that basically sits on the semaphore and processes immediately following a DMA completion. E.G.
PRD_Handle() { ReadFromFIFO(..., mysem); } EDMA_Handler() { while(SEM_pend(mysem, SYS_FOREVER)) { // process data } }
RE: Using dspQDMA library on OMAP-L138 - Added by David Rice about 13 years ago
Typically, we kick off the DMA from an ISR and pend for it in a task. Pending from within an ISR is not allowed. You could kick off the DMA from with the timer function, and pend for the semaphore within a monitoring task. This will avoid the problem of pending in the ISR, and allows the task switch to occur at the same time as the DMA transfer is happening, so the overhead to do the task switch would be (at least partially) covered by the transfer time. Set the priority of the DMA monitoring task pretty high so it doesn't get blocked by a lower priority task.
Dave
RE: Using dspQDMA library on OMAP-L138 - Added by David Rice about 13 years ago
Mike and I apparently were typing simultaneously! Good thing we both came up with the same answer!
Dave
RE: Using dspQDMA library on OMAP-L138 - Added by Rich Bagdazian about 13 years ago
Great! Thanks very much guys. This should get me on the right track.